Skip to contentSkip to conversation

x86/xen: fix arbitrary_virt_to_machine()

PATCH In review Jan Beulich 3 participants 5 messages May 15, 2008 – May 16, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/xen: fix arbitrary_virt_to_machine()

While I realize that the function isn't currently being used, I still think an obvious mistake like this should be corrected.

arch/x86/xen/mmu.c +1 -1
@@ -60,7 +60,7 @@ xmaddr_t arbitrary_virt_to_machine(unsig
 {
 	unsigned int level;
 	pte_t *pte = lookup_address(address, &level);
-	unsigned offset = address & PAGE_MASK;
+	unsigned offset = address & (PAGE_SIZE - 1);
 
 	BUG_ON(pte == NULL);
 
#1 lore raw
Quoted 8 lines · Jan Beulich

While I realize that the function isn't currently being used, I still think an obvious mistake like this should be corrected.

arch/x86/xen/mmu.c xmaddr_t arbitrary_virt_to_machine(unsig · line 64

Quoted 6 lines
arch/x86/xen/mmu.c +1 -1
@@ -60,7 +60,7 @@ xmaddr_t arbitrary_virt_to_machine(unsig
 {
 	unsigned int level;
 	pte_t *pte = lookup_address(address, &level);
-	unsigned offset = address & PAGE_MASK;
+	unsigned offset = address & (PAGE_SIZE - 1);
 

Yeah. But I'd prefer "~PAGE_MASK".

J

Acked-by Jeremy Fitzhardinge
#2 lore raw
Quoted 6 lines · Jeremy Fitzhardinge
Quoted 5 lines · Jan Beulich

While I realize that the function isn't currently being used, I still think an obvious mistake like this should be corrected.

Quoted 11 lines

arch/x86/xen/mmu.c xmaddr_t arbitrary_virt_to_machine(unsig · line 64

Quoted 9 lines
arch/x86/xen/mmu.c +1 -1
@@ -60,7 +60,7 @@ xmaddr_t arbitrary_virt_to_machine(unsig
 {
 	unsigned int level;
 	pte_t *pte = lookup_address(address, &level);
-	unsigned offset = address & PAGE_MASK;
+	unsigned offset = address & (PAGE_SIZE - 1);
 

Yeah. But I'd prefer "~PAGE_MASK".

ok - queued up the patch below in -tip.

Ingo

----------------------->
Subject: x86/xen: fix arbitrary_virt_to_machine()
From: "Jan Beulich" <[email protected]>
Date: Thu, 15 May 2008 13:24:52 +0100

While I realize that the function isn't currently being used, I still think an obvious mistake like this should be corrected.

---
 arch/x86/xen/mmu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/mmu.c +1 -1
Index: linux/arch/x86/xen/mmu.c
===================================================================
@@ -60,7 +60,7 @@ xmaddr_t arbitrary_virt_to_machine(unsig
 {
 	unsigned int level;
 	pte_t *pte = lookup_address(address, &level);
-	unsigned offset = address & PAGE_MASK;
+	unsigned offset = address & ~PAGE_SIZE;
 
 	BUG_ON(pte == NULL);
 
#3 lore raw

arch/x86/xen/mmu.c xmaddr_t arbitrary_virt_to_machine(unsig · line 63

Quoted 5 lines · Ingo Molnar
arch/x86/xen/mmu.c +1 -1
 	unsigned int level;
 	pte_t *pte = lookup_address(address, &level);
-	unsigned offset = address & PAGE_MASK;
+	unsigned offset = address & ~PAGE_SIZE;

Ah, no, you have the worst of both worlds there ;) Should be ~PAGE_*MASK*.

J

#4 lore raw
Quoted 8 lines · Jeremy Fitzhardinge

arch/x86/xen/mmu.c xmaddr_t arbitrary_virt_to_machine(unsig · line 63

Quoted 5 lines · Ingo Molnar
arch/x86/xen/mmu.c +1 -1
 	unsigned int level;
 	pte_t *pte = lookup_address(address, &level);
-	unsigned offset = address & PAGE_MASK;
+	unsigned offset = address & ~PAGE_SIZE;

Ah, no, you have the worst of both worlds there ;) Should be ~PAGE_*MASK*.

argh :-) fixed.

Ingo