From: "Jan Beulich" Subject: [PATCH v5 3/4] x86/vlapic: a few type adjustments Date: Wed, 24 Sep 2014 16:36:27 +0100 Message-ID: <5423011B02000078000386DD@mail.emea.novell.com> References: <5422FF2E0200007800038693@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part11246AEB.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWocJ-000116-5X for xen-devel@lists.xenproject.org; Wed, 24 Sep 2014 15:36:31 +0000 In-Reply-To: <5422FF2E0200007800038693@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. --=__Part11246AEB.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Constify a couple of pointer parameters, convert a boolean function return type to bool_t, and clean up a printk() being touched anyway. Suggested-by: Andrew Cooper Signed-off-by: Jan Beulich --- v5: Move some more type changes from patch 2 to here. --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -173,9 +173,10 @@ uint32_t vlapic_set_ppr(struct vlapic *v return ppr; } =20 -static int vlapic_match_logical_addr(struct vlapic *vlapic, uint32_t mda) +static bool_t vlapic_match_logical_addr(const struct vlapic *vlapic, + uint32_t mda) { - int result =3D 0; + bool_t result =3D 0; uint32_t logical_id =3D vlapic_get_reg(vlapic, APIC_LDR); =20 if ( vlapic_x2apic_mode(vlapic) ) @@ -196,9 +197,9 @@ static int vlapic_match_logical_addr(str result =3D 1; break; default: - gdprintk(XENLOG_WARNING, "Bad DFR value for lapic of vcpu %d: = %08x\n", - vlapic_vcpu(vlapic)->vcpu_id, - vlapic_get_reg(vlapic, APIC_DFR)); + printk(XENLOG_G_WARNING "%pv: bad LAPIC DFR value %08x\n", + const_vlapic_vcpu(vlapic), + vlapic_get_reg(vlapic, APIC_DFR)); break; } =20 @@ -206,8 +207,8 @@ static int vlapic_match_logical_addr(str } =20 bool_t vlapic_match_dest( - struct vlapic *target, struct vlapic *source, - int short_hand, uint32_t dest, uint8_t dest_mode) + const struct vlapic *target, const struct vlapic *source, + int short_hand, uint32_t dest, bool_t dest_mode) { HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "target %p, source %p, dest %#x, " "dest_mode %#x, short_hand %#x", @@ -286,7 +287,7 @@ static void vlapic_init_sipi_action(unsi uint32_t icr =3D vcpu_vlapic(origin)->init_sipi.icr; uint32_t dest =3D vcpu_vlapic(origin)->init_sipi.dest; uint32_t short_hand =3D icr & APIC_SHORT_MASK; - uint32_t dest_mode =3D !!(icr & APIC_DEST_MASK); + bool_t dest_mode =3D !!(icr & APIC_DEST_MASK); struct vcpu *v; =20 if ( icr =3D=3D 0 ) @@ -352,8 +353,8 @@ static void vlapic_accept_irq(struct vcp } =20 struct vlapic *vlapic_lowest_prio( - struct domain *d, struct vlapic *source, - int short_hand, uint32_t dest, uint8_t dest_mode) + struct domain *d, const struct vlapic *source, + int short_hand, uint32_t dest, bool_t dest_mode) { int old =3D d->arch.hvm_domain.irq.round_robin_prev_vcpu; uint32_t ppr, target_ppr =3D UINT_MAX; @@ -434,7 +435,7 @@ void vlapic_ipi( { unsigned int dest; unsigned int short_hand =3D icr_low & APIC_SHORT_MASK; - unsigned int dest_mode =3D !!(icr_low & APIC_DEST_MASK); + bool_t dest_mode =3D !!(icr_low & APIC_DEST_MASK); =20 HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "icr =3D 0x%08x:%08x", icr_high, = icr_low); =20 --- a/xen/include/asm-x86/hvm/vlapic.h +++ b/xen/include/asm-x86/hvm/vlapic.h @@ -28,6 +28,8 @@ =20 #define vcpu_vlapic(x) (&(x)->arch.hvm_vcpu.vlapic) #define vlapic_vcpu(x) (container_of((x), struct vcpu, arch.hvm_vcpu.vla= pic)) +#define const_vlapic_vcpu(x) (container_of((x), const struct vcpu, \ + arch.hvm_vcpu.vlapic)) #define vlapic_domain(x) (vlapic_vcpu(x)->domain) =20 #define _VLAPIC_ID(vlapic, id) (vlapic_x2apic_mode(vlapic) \ @@ -88,7 +90,8 @@ struct vlapic { /* vlapic's frequence is 100 MHz */ #define APIC_BUS_CYCLE_NS 10 =20 -static inline uint32_t vlapic_get_reg(struct vlapic *vlapic, uint32_t = reg) +static inline uint32_t vlapic_get_reg(const struct vlapic *vlapic, + uint32_t reg) { return *((uint32_t *)(&vlapic->regs->data[reg])); } @@ -128,11 +131,11 @@ void vlapic_ipi(struct vlapic *vlapic, u int vlapic_apicv_write(struct vcpu *v, unsigned int offset); =20 struct vlapic *vlapic_lowest_prio( - struct domain *d, struct vlapic *source, - int short_hand, uint32_t dest, uint8_t dest_mode); + struct domain *d, const struct vlapic *source, + int short_hand, uint32_t dest, bool_t dest_mode); =20 bool_t vlapic_match_dest( - struct vlapic *target, struct vlapic *source, - int short_hand, uint32_t dest, uint8_t dest_mode); + const struct vlapic *target, const struct vlapic *source, + int short_hand, uint32_t dest, bool_t dest_mode); =20 #endif /* __ASM_X86_HVM_VLAPIC_H__ */ --=__Part11246AEB.1__= Content-Type: text/plain; name="x86-HVM-x2APIC-types.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-HVM-x2APIC-types.patch" x86/vlapic: a few type adjustments=0A=0AConstify a couple of pointer = parameters, convert a boolean function=0Areturn type to bool_t, and clean = up a printk() being touched anyway.=0A=0ASuggested-by: Andrew Cooper = =0ASigned-off-by: Jan Beulich =0A---=0Av5: Move some more type changes from patch 2 to here.=0A=0A--- = a/xen/arch/x86/hvm/vlapic.c=0A+++ b/xen/arch/x86/hvm/vlapic.c=0A@@ -173,9 = +173,10 @@ uint32_t vlapic_set_ppr(struct vlapic *v=0A return ppr;=0A = }=0A =0A-static int vlapic_match_logical_addr(struct vlapic *vlapic, = uint32_t mda)=0A+static bool_t vlapic_match_logical_addr(const struct = vlapic *vlapic,=0A+ uint32_t = mda)=0A {=0A- int result =3D 0;=0A+ bool_t result =3D 0;=0A = uint32_t logical_id =3D vlapic_get_reg(vlapic, APIC_LDR);=0A =0A if ( = vlapic_x2apic_mode(vlapic) )=0A@@ -196,9 +197,9 @@ static int vlapic_match_= logical_addr(str=0A result =3D 1;=0A break;=0A = default:=0A- gdprintk(XENLOG_WARNING, "Bad DFR value for lapic of = vcpu %d: %08x\n",=0A- vlapic_vcpu(vlapic)->vcpu_id,=0A- = vlapic_get_reg(vlapic, APIC_DFR));=0A+ printk(XENLOG_G_= WARNING "%pv: bad LAPIC DFR value %08x\n",=0A+ const_vlapic_v= cpu(vlapic),=0A+ vlapic_get_reg(vlapic, APIC_DFR));=0A = break;=0A }=0A =0A@@ -206,8 +207,8 @@ static int vlapic_match_logical= _addr(str=0A }=0A =0A bool_t vlapic_match_dest(=0A- struct vlapic = *target, struct vlapic *source,=0A- int short_hand, uint32_t dest, = uint8_t dest_mode)=0A+ const struct vlapic *target, const struct vlapic = *source,=0A+ int short_hand, uint32_t dest, bool_t dest_mode)=0A {=0A = HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "target %p, source %p, dest %#x, "=0A = "dest_mode %#x, short_hand %#x",=0A@@ -286,7 +287,7 @@ static = void vlapic_init_sipi_action(unsi=0A uint32_t icr =3D vcpu_vlapic(origi= n)->init_sipi.icr;=0A uint32_t dest =3D vcpu_vlapic(origin)->init_sipi.= dest;=0A uint32_t short_hand =3D icr & APIC_SHORT_MASK;=0A- = uint32_t dest_mode =3D !!(icr & APIC_DEST_MASK);=0A+ bool_t dest_mode = =3D !!(icr & APIC_DEST_MASK);=0A struct vcpu *v;=0A =0A if ( icr = =3D=3D 0 )=0A@@ -352,8 +353,8 @@ static void vlapic_accept_irq(struct = vcp=0A }=0A =0A struct vlapic *vlapic_lowest_prio(=0A- struct domain = *d, struct vlapic *source,=0A- int short_hand, uint32_t dest, uint8_t = dest_mode)=0A+ struct domain *d, const struct vlapic *source,=0A+ = int short_hand, uint32_t dest, bool_t dest_mode)=0A {=0A int old =3D = d->arch.hvm_domain.irq.round_robin_prev_vcpu;=0A uint32_t ppr, = target_ppr =3D UINT_MAX;=0A@@ -434,7 +435,7 @@ void vlapic_ipi(=0A {=0A = unsigned int dest;=0A unsigned int short_hand =3D icr_low & APIC_SHORT= _MASK;=0A- unsigned int dest_mode =3D !!(icr_low & APIC_DEST_MASK);=0A+= bool_t dest_mode =3D !!(icr_low & APIC_DEST_MASK);=0A =0A = HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "icr =3D 0x%08x:%08x", icr_high, icr_low);=0A= =0A--- a/xen/include/asm-x86/hvm/vlapic.h=0A+++ b/xen/include/asm-x86/hvm/= vlapic.h=0A@@ -28,6 +28,8 @@=0A =0A #define vcpu_vlapic(x) (&(x)->arch.hv= m_vcpu.vlapic)=0A #define vlapic_vcpu(x) (container_of((x), struct vcpu, = arch.hvm_vcpu.vlapic))=0A+#define const_vlapic_vcpu(x) (container_of((x), = const struct vcpu, \=0A+ arch.hvm_vcpu.vlapic)= )=0A #define vlapic_domain(x) (vlapic_vcpu(x)->domain)=0A =0A #define = _VLAPIC_ID(vlapic, id) (vlapic_x2apic_mode(vlapic) \=0A@@ -88,7 +90,8 @@ = struct vlapic {=0A /* vlapic's frequence is 100 MHz */=0A #define = APIC_BUS_CYCLE_NS 10=0A =0A-static inline uint32_t vlapic_get= _reg(struct vlapic *vlapic, uint32_t reg)=0A+static inline uint32_t = vlapic_get_reg(const struct vlapic *vlapic,=0A+ = uint32_t reg)=0A {=0A return *((uint32_t *)(&vlapic->regs->da= ta[reg]));=0A }=0A@@ -128,11 +131,11 @@ void vlapic_ipi(struct vlapic = *vlapic, u=0A int vlapic_apicv_write(struct vcpu *v, unsigned int = offset);=0A =0A struct vlapic *vlapic_lowest_prio(=0A- struct domain = *d, struct vlapic *source,=0A- int short_hand, uint32_t dest, uint8_t = dest_mode);=0A+ struct domain *d, const struct vlapic *source,=0A+ = int short_hand, uint32_t dest, bool_t dest_mode);=0A =0A bool_t vlapic_matc= h_dest(=0A- struct vlapic *target, struct vlapic *source,=0A- int = short_hand, uint32_t dest, uint8_t dest_mode);=0A+ const struct vlapic = *target, const struct vlapic *source,=0A+ int short_hand, uint32_t = dest, bool_t dest_mode);=0A =0A #endif /* __ASM_X86_HVM_VLAPIC_H__ */=0A --=__Part11246AEB.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 --=__Part11246AEB.1__=--