lkml.org 
[lkml]   [2020]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2 4/4] KVM: SVM: Use __packed shorthand
Date
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)

\
 
 \ /
  Last update: 2020-07-30 18:23    [W:0.121 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site