From: "Jan Beulich" Subject: [PATCH 2/4] x86/HVM: replace plain numbers Date: Thu, 22 Jan 2015 13:57:51 +0000 Message-ID: <54C10FEF0200007800058295@mail.emea.novell.com> References: <54C10EE1020000780005827E@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3306ABCF.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YEIGf-0004NE-2r for xen-devel@lists.xenproject.org; Thu, 22 Jan 2015 13:57:53 +0000 In-Reply-To: <54C10EE1020000780005827E@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser 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. --=__Part3306ABCF.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... making the code better document itself. No functional change intended. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/vioapic.c +++ b/xen/arch/x86/hvm/vioapic.c @@ -53,18 +53,26 @@ static uint32_t vioapic_read_indirect(co switch ( vioapic->ioregsel ) { case VIOAPIC_REG_VERSION: - result =3D ((((VIOAPIC_NUM_PINS-1) & 0xff) << 16) - | (VIOAPIC_VERSION_ID & 0xff)); + result =3D ((union IO_APIC_reg_01){ + .bits =3D { .version =3D VIOAPIC_VERSION_ID, + .entries =3D VIOAPIC_NUM_PINS - 1 } + }).raw; break; =20 case VIOAPIC_REG_APIC_ID: + /* + * Using union IO_APIC_reg_02 for the ID register too, as + * union IO_APIC_reg_00's ID field is 8 bits wide for some = reason. + */ case VIOAPIC_REG_ARB_ID: - result =3D ((vioapic->id & 0xf) << 24); + result =3D ((union IO_APIC_reg_02){ + .bits =3D { .arbitration =3D vioapic->id } + }).raw; break; =20 default: { - uint32_t redir_index =3D (vioapic->ioregsel - 0x10) >> 1; + uint32_t redir_index =3D (vioapic->ioregsel - VIOAPIC_REG_RTE0) = >> 1; uint64_t redir_content; =20 if ( redir_index >=3D VIOAPIC_NUM_PINS ) @@ -173,7 +181,11 @@ static void vioapic_write_indirect( break; =20 case VIOAPIC_REG_APIC_ID: - vioapic->id =3D (val >> 24) & 0xf; + /* + * Using union IO_APIC_reg_02 for the ID register, as for some + * reason union IO_APIC_reg_00's ID field is 8 bits wide. + */ + vioapic->id =3D ((union IO_APIC_reg_02){ .raw =3D val }).bits.arbi= tration; break; =20 case VIOAPIC_REG_ARB_ID: @@ -181,7 +193,7 @@ static void vioapic_write_indirect( =20 default: { - uint32_t redir_index =3D (vioapic->ioregsel - 0x10) >> 1; + uint32_t redir_index =3D (vioapic->ioregsel - VIOAPIC_REG_RTE0) = >> 1; =20 HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "rte[%02x].%s =3D %08x", redir_index, vioapic->ioregsel & 1 ? "hi" : "lo", = val); --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -835,7 +835,7 @@ static int vlapic_write(struct vcpu *v,=20 unsigned int offset =3D address - vlapic_base_address(vlapic); int rc =3D X86EMUL_OKAY; =20 - if ( offset !=3D 0xb0 ) + if ( offset !=3D APIC_EOI ) HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "offset %#x with length %#lx, and value is %#lx", offset, len, val); --- a/xen/include/asm-x86/hvm/vioapic.h +++ b/xen/include/asm-x86/hvm/vioapic.h @@ -47,6 +47,7 @@ #define VIOAPIC_REG_APIC_ID 0x00 /* x86 IOAPIC only */ #define VIOAPIC_REG_VERSION 0x01 #define VIOAPIC_REG_ARB_ID 0x02 /* x86 IOAPIC only */ +#define VIOAPIC_REG_RTE0 0x10 =20 struct hvm_vioapic { struct hvm_hw_vioapic hvm_hw_vioapic; --=__Part3306ABCF.1__= Content-Type: text/plain; name="x86-HVM-literals.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-HVM-literals.patch" x86/HVM: replace plain numbers=0A=0A... making the code better document = itself. No functional change=0Aintended.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/x86/hvm/vioapic.c=0A+++ b/xen/arch/= x86/hvm/vioapic.c=0A@@ -53,18 +53,26 @@ static uint32_t vioapic_read_indire= ct(co=0A switch ( vioapic->ioregsel )=0A {=0A case VIOAPIC_REG_= VERSION:=0A- result =3D ((((VIOAPIC_NUM_PINS-1) & 0xff) << 16)=0A- = | (VIOAPIC_VERSION_ID & 0xff));=0A+ result =3D = ((union IO_APIC_reg_01){=0A+ .bits =3D { .version =3D = VIOAPIC_VERSION_ID,=0A+ .entries =3D VIOAPIC_NUM= _PINS - 1 }=0A+ }).raw;=0A break;=0A =0A case = VIOAPIC_REG_APIC_ID:=0A+ /*=0A+ * Using union IO_APIC_reg_02= for the ID register too, as=0A+ * union IO_APIC_reg_00's ID field = is 8 bits wide for some reason.=0A+ */=0A case VIOAPIC_REG_ARB_= ID:=0A- result =3D ((vioapic->id & 0xf) << 24);=0A+ result = =3D ((union IO_APIC_reg_02){=0A+ .bits =3D { .arbitration = =3D vioapic->id }=0A+ }).raw;=0A break;=0A =0A = default:=0A {=0A- uint32_t redir_index =3D (vioapic->ioregsel = - 0x10) >> 1;=0A+ uint32_t redir_index =3D (vioapic->ioregsel - = VIOAPIC_REG_RTE0) >> 1;=0A uint64_t redir_content;=0A =0A = if ( redir_index >=3D VIOAPIC_NUM_PINS )=0A@@ -173,7 +181,11 @@ static = void vioapic_write_indirect(=0A break;=0A =0A case VIOAPIC_REG_= APIC_ID:=0A- vioapic->id =3D (val >> 24) & 0xf;=0A+ /*=0A+ = * Using union IO_APIC_reg_02 for the ID register, as for some=0A+ = * reason union IO_APIC_reg_00's ID field is 8 bits wide.=0A+ = */=0A+ vioapic->id =3D ((union IO_APIC_reg_02){ .raw =3D val = }).bits.arbitration;=0A break;=0A =0A case VIOAPIC_REG_ARB_ID:= =0A@@ -181,7 +193,7 @@ static void vioapic_write_indirect(=0A =0A = default:=0A {=0A- uint32_t redir_index =3D (vioapic->ioregsel - = 0x10) >> 1;=0A+ uint32_t redir_index =3D (vioapic->ioregsel - = VIOAPIC_REG_RTE0) >> 1;=0A =0A HVM_DBG_LOG(DBG_LEVEL_IOAPIC, = "rte[%02x].%s =3D %08x",=0A redir_index, vioapic->ioreg= sel & 1 ? "hi" : "lo", val);=0A--- a/xen/arch/x86/hvm/vlapic.c=0A+++ = b/xen/arch/x86/hvm/vlapic.c=0A@@ -835,7 +835,7 @@ static int vlapic_write(s= truct vcpu *v, =0A unsigned int offset =3D address - vlapic_base_addres= s(vlapic);=0A int rc =3D X86EMUL_OKAY;=0A =0A- if ( offset !=3D = 0xb0 )=0A+ if ( offset !=3D APIC_EOI )=0A HVM_DBG_LOG(DBG_LEVEL_= VLAPIC,=0A "offset %#x with length %#lx, and value is = %#lx",=0A offset, len, val);=0A--- a/xen/include/asm-x8= 6/hvm/vioapic.h=0A+++ b/xen/include/asm-x86/hvm/vioapic.h=0A@@ -47,6 +47,7 = @@=0A #define VIOAPIC_REG_APIC_ID 0x00 /* x86 IOAPIC only */=0A #define = VIOAPIC_REG_VERSION 0x01=0A #define VIOAPIC_REG_ARB_ID 0x02 /* x86 IOAPIC = only */=0A+#define VIOAPIC_REG_RTE0 0x10=0A =0A struct hvm_vioapic {=0A = struct hvm_hw_vioapic hvm_hw_vioapic;=0A --=__Part3306ABCF.1__= 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.xen.org http://lists.xen.org/xen-devel --=__Part3306ABCF.1__=--