Skip to contentSkip to conversation

x86/platform/uv: Fix calculation of Global Physical Address

PATCH New Mike Travis 2 participants 2 messages Mar 21, 2017 – Mar 22, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 x86/platform/uv: Fix calculation of Global Physical Address

The calculation of the global physical address (GPA) on UV4 is incorrect. The gnode_extra/upper global offset should only be applied for fixed address space systems (UV1..3).

---
 arch/x86/include/asm/uv/uv_hub.h   |    8 +++++---
 arch/x86/kernel/apic/x2apic_uv_x.c |    3 ++-
 2 files changed, 7 insertions(+), 4 deletions(-)
arch/x86/include/asm/uv/uv_hub.h +5 -3
@@ -485,15 +485,17 @@ static inline unsigned long uv_soc_phys_
 
 	if (paddr < uv_hub_info->lowmem_remap_top)
 		paddr |= uv_hub_info->lowmem_remap_base;
-	paddr |= uv_hub_info->gnode_upper;
-	if (m_val)
+
+	if (m_val) {
+		paddr |= uv_hub_info->gnode_upper;
 		paddr = ((paddr << uv_hub_info->m_shift)
 						>> uv_hub_info->m_shift) |
 			((paddr >> uv_hub_info->m_val)
 						<< uv_hub_info->n_lshift);
-	else
+	} else {
 		paddr |= uv_soc_phys_ram_to_nasid(paddr)
 						<< uv_hub_info->gpa_shift;
+	}
 	return paddr;
 }
 
arch/x86/kernel/apic/x2apic_uv_x.c +2 -1
@@ -1105,7 +1105,8 @@ void __init uv_init_hub_info(struct uv_h
 	node_id.v		= uv_read_local_mmr(UVH_NODE_ID);
 	uv_cpuid.gnode_shift	= max_t(unsigned int, uv_cpuid.gnode_shift, mn.n_val);
 	hi->gnode_extra		= (node_id.s.node_id & ~((1 << uv_cpuid.gnode_shift) - 1)) >> 1;
-	hi->gnode_upper		= (unsigned long)hi->gnode_extra << mn.m_val;
+	if (mn.m_val)
+		hi->gnode_upper	= (u64)hi->gnode_extra << mn.m_val;
 
 	if (uv_gp_table) {
 		hi->global_mmr_base	= uv_gp_table->mmr_base;
#2 lore raw
x86/platform/uv: Fix calculation of Global Physical Address
Commit-ID:  ad4830051aac0b967add82ac168f49edf11f01a0
Gitweb:     http://git.kernel.org/tip/ad4830051aac0b967add82ac168f49edf11f01a0
Author:     Mike Travis <[email protected]>
AuthorDate: Tue, 21 Mar 2017 18:16:47 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 22 Mar 2017 07:41:10 +0100

x86/platform/uv: Fix calculation of Global Physical Address

The calculation of the global physical address (GPA) on UV4 is incorrect. The gnode_extra/upper global offset should only be applied for fixed address space systems (UV1..3).

---
 arch/x86/include/asm/uv/uv_hub.h   | 8 +++++---
 arch/x86/kernel/apic/x2apic_uv_x.c | 3 ++-
 2 files changed, 7 insertions(+), 4 deletions(-)
arch/x86/include/asm/uv/uv_hub.h +5 -3
index 72e8300..9cffb44 100644
@@ -485,15 +485,17 @@ static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr)
 
 	if (paddr < uv_hub_info->lowmem_remap_top)
 		paddr |= uv_hub_info->lowmem_remap_base;
-	paddr |= uv_hub_info->gnode_upper;
-	if (m_val)
+
+	if (m_val) {
+		paddr |= uv_hub_info->gnode_upper;
 		paddr = ((paddr << uv_hub_info->m_shift)
 						>> uv_hub_info->m_shift) |
 			((paddr >> uv_hub_info->m_val)
 						<< uv_hub_info->n_lshift);
-	else
+	} else {
 		paddr |= uv_soc_phys_ram_to_nasid(paddr)
 						<< uv_hub_info->gpa_shift;
+	}
 	return paddr;
 }
 
arch/x86/kernel/apic/x2apic_uv_x.c +2 -1
index e9f8f8c..86f20cc 100644
@@ -1105,7 +1105,8 @@ void __init uv_init_hub_info(struct uv_hub_info_s *hi)
 	node_id.v		= uv_read_local_mmr(UVH_NODE_ID);
 	uv_cpuid.gnode_shift	= max_t(unsigned int, uv_cpuid.gnode_shift, mn.n_val);
 	hi->gnode_extra		= (node_id.s.node_id & ~((1 << uv_cpuid.gnode_shift) - 1)) >> 1;
-	hi->gnode_upper		= (unsigned long)hi->gnode_extra << mn.m_val;
+	if (mn.m_val)
+		hi->gnode_upper	= (u64)hi->gnode_extra << mn.m_val;
 
 	if (uv_gp_table) {
 		hi->global_mmr_base	= uv_gp_table->mmr_base;