kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Joerg Roedel' <joro@8bytes.org>, Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Borislav Petkov <bp@alien8.de>, Joerg Roedel <jroedel@suse.de>
Subject: RE: [PATCH v2 4/4] KVM: SVM: Use __packed shorthand
Date: Thu, 30 Jul 2020 16:22:38 +0000	[thread overview]
Message-ID: <230e4cc785ff49a38c028474dcfc9c36@AcuMS.aculab.com> (raw)
In-Reply-To: <20200730154340.14021-5-joro@8bytes.org>

From: Joerg Roedel
> Sent: 30 July 2020 16:44
> 
> From: Borislav Petkov <bp@alien8.de>
> 
> Use the shorthand to make it more readable.
...
> diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
> index 8744817358bf..6b4b43f68f4b 100644
> --- a/arch/x86/include/asm/svm.h
> +++ b/arch/x86/include/asm/svm.h
> @@ -150,14 +150,14 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
>  #define SVM_NESTED_CTL_NP_ENABLE	BIT(0)
>  #define SVM_NESTED_CTL_SEV_ENABLE	BIT(1)
> 
> -struct __attribute__ ((__packed__)) vmcb_seg {
> +struct vmcb_seg {
>  	u16 selector;
>  	u16 attrib;
>  	u32 limit;
>  	u64 base;
> -};
> +} __packed;

Why are they marked 'packed' at all?
The above has no holes.
So it would only need to be 'packed' if it might exist at
an unaligned address.
That only tends to happed for network messages and compatibility
with old hardware definitions.

While you might want an attribute for 'error if has holes'
if definitely isn't __packed.

For larger structures in can be worth adding a compile-time
assert that the structure is the size of the associated
hardware registers/structure.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


      reply	other threads:[~2020-07-30 16:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30 15:43 [PATCH v2 0/4] KVM: SVM: SEV-ES groundwork Joerg Roedel
2020-07-30 15:43 ` [PATCH v2 1/4] KVM: SVM: nested: Don't allocate VMCB structures on stack Joerg Roedel
2020-07-30 15:43 ` [PATCH v2 2/4] KVM: SVM: Add GHCB definitions Joerg Roedel
2020-07-30 15:43 ` [PATCH v2 3/4] KVM: SVM: Add GHCB Accessor functions Joerg Roedel
2020-07-31 15:18   ` Sean Christopherson
2020-07-30 15:43 ` [PATCH v2 4/4] KVM: SVM: Use __packed shorthand Joerg Roedel
2020-07-30 16:22   ` David Laight [this message]

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=230e4cc785ff49a38c028474dcfc9c36@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=bp@alien8.de \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=thomas.lendacky@amd.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    /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).