From: "Tian, Kevin" <kevin.tian@intel.com>
To: Paul Durrant <paul@xen.org>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Paul Durrant" <pdurrant@amazon.com>,
"Nakajima, Jun" <jun.nakajima@intel.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Cooper, Andrew" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>
Subject: RE: [PATCH v3 13/13] x86: replace open-coded occurrences of sizeof_field()...
Date: Mon, 30 Nov 2020 02:48:19 +0000 [thread overview]
Message-ID: <MWHPR11MB1645B36F8461F16F6A6151898CF50@MWHPR11MB1645.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20201124190744.11343-14-paul@xen.org>
> From: Paul Durrant <paul@xen.org>
> Sent: Wednesday, November 25, 2020 3:08 AM
>
> From: Paul Durrant <pdurrant@amazon.com>
>
> ... with macro evaluations, now that it is available.
>
> A recent patch imported the sizeof_field() macro from Linux. This patch
> makes
> use of it in places where the construct is currently open-coded.
>
> Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> ---
> Cc: Jun Nakajima <jun.nakajima@intel.com>
> Cc: Kevin Tian <kevin.tian@intel.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: "Roger Pau Monné" <roger.pau@citrix.com>
> Cc: Wei Liu <wl@xen.org>
> ---
> xen/arch/x86/cpu/vpmu_intel.c | 4 ++--
> xen/arch/x86/setup.c | 16 ++++++++--------
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/xen/arch/x86/cpu/vpmu_intel.c
> b/xen/arch/x86/cpu/vpmu_intel.c
> index 75aa11c6adec..6e97ce790037 100644
> --- a/xen/arch/x86/cpu/vpmu_intel.c
> +++ b/xen/arch/x86/cpu/vpmu_intel.c
> @@ -90,8 +90,8 @@ static uint64_t __read_mostly global_ovf_ctrl_mask,
> global_ctrl_mask;
> static unsigned int __read_mostly regs_sz;
> /* Offset into context of the beginning of PMU register block */
> static const unsigned int regs_off =
> - sizeof(((struct xen_pmu_intel_ctxt *)0)->fixed_counters) +
> - sizeof(((struct xen_pmu_intel_ctxt *)0)->arch_counters);
> + sizeof_field(struct xen_pmu_intel_ctxt, fixed_counters) +
> + sizeof_field(struct xen_pmu_intel_ctxt, arch_counters);
>
> /*
> * QUIRK to workaround an issue on various family 6 cpus.
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 44c04e273537..30d6f375a3af 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -1617,19 +1617,19 @@ void __init noreturn __start_xen(unsigned long
> mbi_p)
> total_pages = nr_pages;
>
> /* Sanity check for unwanted bloat of certain hypercall structures. */
> - BUILD_BUG_ON(sizeof(((struct xen_platform_op *)0)->u) !=
> - sizeof(((struct xen_platform_op *)0)->u.pad));
> - BUILD_BUG_ON(sizeof(((struct xen_domctl *)0)->u) !=
> - sizeof(((struct xen_domctl *)0)->u.pad));
> - BUILD_BUG_ON(sizeof(((struct xen_sysctl *)0)->u) !=
> - sizeof(((struct xen_sysctl *)0)->u.pad));
> + BUILD_BUG_ON(sizeof_field(struct xen_platform_op, u) !=
> + sizeof_field(struct xen_platform_op, u.pad));
> + BUILD_BUG_ON(sizeof_field(struct xen_domctl, u) !=
> + sizeof_field(struct xen_domctl, u.pad));
> + BUILD_BUG_ON(sizeof_field(struct xen_sysctl, u) !=
> + sizeof_field(struct xen_sysctl, u.pad));
>
> BUILD_BUG_ON(sizeof(start_info_t) > PAGE_SIZE);
> BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE);
> BUILD_BUG_ON(sizeof(struct vcpu_info) != 64);
>
> - BUILD_BUG_ON(sizeof(((struct compat_platform_op *)0)->u) !=
> - sizeof(((struct compat_platform_op *)0)->u.pad));
> + BUILD_BUG_ON(sizeof_field(struct compat_platform_op, u) !=
> + sizeof_field(struct compat_platform_op, u.pad));
> BUILD_BUG_ON(sizeof(start_info_compat_t) > PAGE_SIZE);
> BUILD_BUG_ON(sizeof(struct compat_vcpu_info) != 64);
>
> --
> 2.20.1
next prev parent reply other threads:[~2020-11-30 2:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 19:07 [PATCH v3 00/13] viridian: add support for ExProcessorMasks Paul Durrant
2020-11-24 19:07 ` [PATCH v3 01/13] viridian: don't blindly write to 32-bit registers is 'mode' is invalid Paul Durrant
2020-11-25 7:51 ` Jan Beulich
2020-11-25 7:58 ` Durrant, Paul
2020-11-24 19:07 ` [PATCH v3 02/13] viridian: move flush hypercall implementation into separate function Paul Durrant
2020-11-24 19:07 ` [PATCH v3 03/13] viridian: move IPI " Paul Durrant
2020-11-24 19:07 ` [PATCH v3 04/13] viridian: introduce a per-cpu hypercall_vpmask and accessor functions Paul Durrant
2020-11-24 19:07 ` [PATCH v3 05/13] viridian: use hypercall_vpmask in hvcall_ipi() Paul Durrant
2020-11-24 19:07 ` [PATCH v3 06/13] viridian: use softirq batching " Paul Durrant
2020-11-24 19:07 ` [PATCH v3 07/13] xen/include: import sizeof_field() macro from Linux stddef.h Paul Durrant
2020-11-24 19:07 ` [PATCH v3 08/13] viridian: add ExProcessorMasks variants of the flush hypercalls Paul Durrant
2020-11-24 19:07 ` [PATCH v3 09/13] viridian: add ExProcessorMasks variant of the IPI hypercall Paul Durrant
2020-11-24 19:07 ` [PATCH v3 10/13] viridian: log initial invocation of each type of hypercall Paul Durrant
2020-11-24 19:07 ` [PATCH v3 11/13] viridian: add a new '_HVMPV_ex_processor_masks' bit into HVM_PARAM_VIRIDIAN Paul Durrant
2020-11-24 19:07 ` [PATCH v3 12/13] xl / libxl: add 'ex_processor_mask' into 'libxl_viridian_enlightenment' Paul Durrant
2020-11-24 19:07 ` [PATCH v3 13/13] x86: replace open-coded occurrences of sizeof_field() Paul Durrant
2020-11-25 7:45 ` Jan Beulich
2020-11-30 2:48 ` Tian, Kevin [this message]
2020-12-01 14:09 ` [EXTERNAL] [PATCH v3 00/13] viridian: add support for ExProcessorMasks Paul Durrant
2020-12-04 10:36 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MWHPR11MB1645B36F8461F16F6A6151898CF50@MWHPR11MB1645.namprd11.prod.outlook.com \
--to=kevin.tian@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=paul@xen.org \
--cc=pdurrant@amazon.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).