From: "Jan Beulich" Subject: [PATCH] x86-64: more fixes for Fam10 MMCONF enabling Date: Fri, 05 Nov 2010 10:44:17 +0000 Message-ID: <4CD3EE110200007800020B64@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part062B9411.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part062B9411.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Unfortunately it turned out the original Linux code had more issues: We want to place the region above 4G in any case (even if TOM2 isn't enabled or invalid), and the base mask definition was improperly typed (thus causing shifts by FAM10H_MMIO_CONF_BASE_SHIFT to produce other than the intended result). Fixing this in turn allowed simplifying the MMIO region detection code, as regions ending below TOM2 now aren't of interest anymore. Signed-off-by: Jan Beulich --- a/xen/include/asm-x86/msr-index.h +++ b/xen/include/asm-x86/msr-index.h @@ -246,7 +246,7 @@ #define FAM10H_MMIO_CONF_ENABLE (1<<0) #define FAM10H_MMIO_CONF_BUSRANGE_MASK 0xf #define FAM10H_MMIO_CONF_BUSRANGE_SHIFT 2 -#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffff +#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffffULL #define FAM10H_MMIO_CONF_BASE_SHIFT 20 =20 /* AMD Microcode MSRs */ --- a/xen/arch/x86/x86_64/mmconf-fam10h.c +++ b/xen/arch/x86/x86_64/mmconf-fam10h.c @@ -28,7 +28,7 @@ static struct pci_hostbridge_probe pci_p { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 }, }; =20 -#define UNIT (1ULL << (5 + 3 + 12)) +#define UNIT (1ULL << FAM10H_MMIO_CONF_BASE_SHIFT) #define MASK (~(UNIT - 1)) #define SIZE (UNIT << 8) /* need to avoid (0xfd<<32) and (0xfe<<32), ht used space */ @@ -68,12 +68,12 @@ static void __init get_fam10h_pci_mmconf =20 /* TOP_MEM2 is not enabled? */ if (!(val & (1<<21))) { - tom2 =3D 0; + tom2 =3D 1ULL << 32; } else { /* TOP_MEM2 */ address =3D MSR_K8_TOP_MEM2; rdmsrl(address, val); - tom2 =3D val & 0xffffff800000ULL; + tom2 =3D max(val & 0xffffff800000ULL, 1ULL << 32); } =20 /* @@ -89,7 +89,7 @@ static void __init get_fam10h_pci_mmconf val =3D pci_conf_read32(bus, slot, 1, 0x84 + (i << 3)); end =3D ((val & 0xffffff00) << 8) | 0xffff; /* 39:16 on = 31:8*/ =20 - if (!end) + if (end < tom2) continue; =20 for (j =3D hi_mmio_num; j; --j) { @@ -119,13 +119,13 @@ static void __init get_fam10h_pci_mmconf if (start > tom2 && BASE_VALID(start)) goto out; start =3D (range[hi_mmio_num - 1].end + UNIT) & MASK; - if (start > tom2 && BASE_VALID(start)) + if (BASE_VALID(start)) goto out; /* need to find window between ranges */ for (i =3D 1; i < hi_mmio_num; i++) { start =3D (range[i - 1].end + UNIT) & MASK; end =3D range[i].start & MASK; - if (end >=3D start + SIZE && start > tom2 && BASE_VALID(sta= rt)) + if (end >=3D start + SIZE && BASE_VALID(start)) goto out; } return; --=__Part062B9411.0__= Content-Type: text/plain; name="x86_64-fam10-mmconf-2.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86_64-fam10-mmconf-2.patch" Unfortunately it turned out the original Linux code had more issues:=0AWe = want to place the region above 4G in any case (even if TOM2 isn't=0Aenabled= or invalid), and the base mask definition was improperly typed=0A(thus = causing shifts by FAM10H_MMIO_CONF_BASE_SHIFT to produce other=0Athan the = intended result). Fixing this in turn allowed simplifying the=0AMMIO = region detection code, as regions ending below TOM2 now aren't of=0Ainteres= t anymore.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/include/asm-x86/msr-index.h=0A+++ b/xen/include/asm-x86/msr-index.h= =0A@@ -246,7 +246,7 @@=0A #define FAM10H_MMIO_CONF_ENABLE = (1<<0)=0A #define FAM10H_MMIO_CONF_BUSRANGE_MASK 0xf=0A #define = FAM10H_MMIO_CONF_BUSRANGE_SHIFT 2=0A-#define FAM10H_MMIO_CONF_BASE_MASK = 0xfffffff=0A+#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffffULL=0A #define = FAM10H_MMIO_CONF_BASE_SHIFT 20=0A =0A /* AMD Microcode MSRs */=0A--- = a/xen/arch/x86/x86_64/mmconf-fam10h.c=0A+++ b/xen/arch/x86/x86_64/mmconf-fa= m10h.c=0A@@ -28,7 +28,7 @@ static struct pci_hostbridge_probe pci_p=0A { = 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 },=0A };=0A =0A-#define UNIT (1ULL << = (5 + 3 + 12))=0A+#define UNIT (1ULL << FAM10H_MMIO_CONF_BASE_SHIFT)=0A = #define MASK (~(UNIT - 1))=0A #define SIZE (UNIT << 8)=0A /* need to avoid = (0xfd<<32) and (0xfe<<32), ht used space */=0A@@ -68,12 +68,12 @@ static = void __init get_fam10h_pci_mmconf=0A =0A /* TOP_MEM2 is not = enabled? */=0A if (!(val & (1<<21))) {=0A- tom2 =3D 0;=0A+ = tom2 =3D 1ULL << 32;=0A } else {=0A /* TOP_MEM2 */=0A = address =3D MSR_K8_TOP_MEM2;=0A rdmsrl(address, = val);=0A- tom2 =3D val & 0xffffff800000ULL;=0A+ = tom2 =3D max(val & 0xffffff800000ULL, 1ULL << 32);=0A }=0A =0A = /*=0A@@ -89,7 +89,7 @@ static void __init get_fam10h_pci_mmconf=0A = val =3D pci_conf_read32(bus, slot, 1, 0x84 + (i << 3));=0A = end =3D ((val & 0xffffff00) << 8) | 0xffff; /* 39:16 on 31:8*/=0A =0A- = if (!end)=0A+ if (end < tom2)=0A = continue;=0A =0A for (j =3D hi_mmio_num; j; --j) {=0A@@ = -119,13 +119,13 @@ static void __init get_fam10h_pci_mmconf=0A if (start = > tom2 && BASE_VALID(start))=0A goto out;=0A start =3D = (range[hi_mmio_num - 1].end + UNIT) & MASK;=0A- if (start > tom2 && = BASE_VALID(start))=0A+ if (BASE_VALID(start))=0A goto = out;=0A /* need to find window between ranges */=0A for (i =3D = 1; i < hi_mmio_num; i++) {=0A start =3D (range[i - 1].end + = UNIT) & MASK;=0A end =3D range[i].start & MASK;=0A- = if (end >=3D start + SIZE && start > tom2 && BASE_VALID(start))=0A+ = if (end >=3D start + SIZE && BASE_VALID(start))=0A = goto out;=0A }=0A return;=0A --=__Part062B9411.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part062B9411.0__=--