From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH 1/4] x86/svm: Clean up construct_vmcb()
Date: Wed, 4 Dec 2019 11:06:21 +0100 [thread overview]
Message-ID: <b9b52155-6773-241d-36a8-1d519af010f1@suse.com> (raw)
In-Reply-To: <20191204094335.24603-2-andrew.cooper3@citrix.com>
On 04.12.2019 10:43, Andrew Cooper wrote:
> The vmcb is zeroed on allocate - drop all explicit writes of 0. Move
> hvm_update_guest_efer() to co-locate it with the other control register
> updates.
>
> Move the BUILD_BUG_ON() into build_assertions(), and add some offset checks
> for fields after the large blocks of reserved fields (as these are the most
> likely to trigger from a mis-edit). Take the opportunity to fold 6 adjacent
> res* fields into one.
>
> Finally, drop all trailing whitespace in the file.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
albeit with two (optional) suggestions:
> @@ -297,14 +258,26 @@ void __init setup_vmcb_dump(void)
>
> static void __init __maybe_unused build_assertions(void)
> {
> - struct segment_register sreg;
> + struct vmcb_struct vmcb;
> +
> + /* Build-time check of the VMCB layout. */
> + BUILD_BUG_ON(sizeof(vmcb) != PAGE_SIZE);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, _pause_filter_thresh) != 0x03c);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, _vintr) != 0x060);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, eventinj) != 0x0a8);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, es) != 0x400);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, _cpl) != 0x4cb);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, _cr4) != 0x548);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, rsp) != 0x5d8);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, rax) != 0x5f8);
> + BUILD_BUG_ON(offsetof(struct vmcb_struct, _g_pat) != 0x668);
>
> /* Check struct segment_register against the VMCB segment layout. */
> - BUILD_BUG_ON(sizeof(sreg) != 16);
> - BUILD_BUG_ON(sizeof(sreg.sel) != 2);
> - BUILD_BUG_ON(sizeof(sreg.attr) != 2);
> - BUILD_BUG_ON(sizeof(sreg.limit) != 4);
> - BUILD_BUG_ON(sizeof(sreg.base) != 8);
> + BUILD_BUG_ON(sizeof(vmcb.es) != 16);
> + BUILD_BUG_ON(sizeof(vmcb.es.sel) != 2);
> + BUILD_BUG_ON(sizeof(vmcb.es.attr) != 2);
> + BUILD_BUG_ON(sizeof(vmcb.es.limit) != 4);
> + BUILD_BUG_ON(sizeof(vmcb.es.base) != 8);
> BUILD_BUG_ON(offsetof(struct segment_register, sel) != 0);
> BUILD_BUG_ON(offsetof(struct segment_register, attr) != 2);
> BUILD_BUG_ON(offsetof(struct segment_register, limit) != 4);
For the ones only supplying context here, how about using the
shorter offsetof(typeof(vmcb.es), ...), also tying things better
to the prior sizeof() checks? The same, albeit to a lesser degree,
might then go for the earlier block, which could use the shorter
typeof(vmcb).
> --- a/xen/include/asm-x86/hvm/svm/vmcb.h
> +++ b/xen/include/asm-x86/hvm/svm/vmcb.h
> @@ -406,12 +406,7 @@ struct vmcb_struct {
> u32 _exception_intercepts; /* offset 0x08 - cleanbit 0 */
> u32 _general1_intercepts; /* offset 0x0C - cleanbit 0 */
> u32 _general2_intercepts; /* offset 0x10 - cleanbit 0 */
> - u32 res01; /* offset 0x14 */
> - u64 res02; /* offset 0x18 */
> - u64 res03; /* offset 0x20 */
> - u64 res04; /* offset 0x28 */
> - u64 res05; /* offset 0x30 */
> - u32 res06; /* offset 0x38 */
> + u32 res01[10];
Was it intentional for the comment to be lost altogether?
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-12-04 10:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 9:43 [Xen-devel] [PATCH 0/4] x86/svm: (Post TASK_SWITCH) cleanup Andrew Cooper
2019-12-04 9:43 ` [Xen-devel] [PATCH 1/4] x86/svm: Clean up construct_vmcb() Andrew Cooper
2019-12-04 10:06 ` Jan Beulich [this message]
2019-12-04 19:21 ` Andrew Cooper
2019-12-04 9:43 ` [Xen-devel] [PATCH 2/4] x86/svm: Don't shadow variables in svm_vmexit_handler() Andrew Cooper
2019-12-04 10:10 ` Jan Beulich
2019-12-04 9:43 ` [Xen-devel] [PATCH 3/4] x86/svm: Clean up intinfo_t variables Andrew Cooper
2019-12-04 10:19 ` Jan Beulich
2019-12-04 19:22 ` Andrew Cooper
2019-12-04 19:38 ` Andrew Cooper
2019-12-05 9:11 ` Jan Beulich
2019-12-05 12:33 ` Andrew Cooper
2019-12-04 9:43 ` [Xen-devel] [PATCH 4/4] x86/svm: Use named (bit)fields for task switch exit info Andrew Cooper
2019-12-04 10:24 ` Jan Beulich
2019-12-04 20:04 ` Andrew Cooper
2019-12-05 9:05 ` Jan Beulich
2019-12-05 10:51 ` [Xen-devel] [PATCH 5/4] x86/svm: Minor cleanup to start_svm() Andrew Cooper
2019-12-05 10:53 ` Jan Beulich
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=b9b52155-6773-241d-36a8-1d519af010f1@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.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).