public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Roman Kagan <rkagan@virtuozzo.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Stephen Hemminger" <sthemmin@microsoft.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"Michael Kelley (EOSG)" <Michael.H.Kelley@microsoft.com>,
	"Nadav Amit" <nadav.amit@gmail.com>,
	"Thomas Gleixner" <tglx@linutronix.de>
Subject: Re: [PATCH] x86/hyper-v: define structures from TLFS as packed
Date: Fri, 30 Nov 2018 14:44:54 +0100	[thread overview]
Message-ID: <87va4ewug9.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20181130131122.GA2358@rkaganb.sw.ru>

Roman Kagan <rkagan@virtuozzo.com> writes:

> On Fri, Nov 30, 2018 at 01:15:11PM +0100, Vitaly Kuznetsov wrote:
>> Without 'packed' compiler is free to add optimization paddings and re-order
>> structure fields for randomization/optimization. And structures from
>> hyperv-tlfs.h are used for hypervisor-guest communication, we need to
>> ultimately forbid such practices.
>
> Note that __packed also reduces the structure alignment to 1, which is
> not necessarily what you want.
>
> E.g. some of these structures are passed by pointer to the hypercall,
> which requires its arguments to be 8byte-aligned.

Hm,

I thought we always take precautions for Hyper-V hypercall arguments, in
particular

PV IPI/TLB flush use pre-allocated hyperv_pcpu_input_arg,
hv_post_message() uses pre-allocated message page, other call sites use
fast hypercalls where we use registers.

I also checked this patch before sending out, WS2016 guest boots without
issues. Any particular places you're worried about?

>  I'm also not sure
> that passing unaligned argument to [rw]msr is ok, need to
> double-check.

My understanding is that rdmsr/wrmsr instuctions are registers-only.

We can, of course, just add __aligned(8) to some structures but I'd like
to find the reason first.

-- 
Vitaly

  parent reply	other threads:[~2018-11-30 13:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-30 12:15 [PATCH] x86/hyper-v: define structures from TLFS as packed Vitaly Kuznetsov
2018-11-30 12:34 ` Thomas Gleixner
2018-11-30 12:49   ` Vitaly Kuznetsov
2018-11-30 13:11 ` Roman Kagan
2018-11-30 13:38   ` Thomas Gleixner
2018-11-30 13:44   ` Vitaly Kuznetsov [this message]
2018-11-30 14:26     ` Roman Kagan
2018-11-30 15:10       ` Vitaly Kuznetsov

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=87va4ewug9.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=Michael.H.Kelley@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kvm@vger.kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nadav.amit@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=rkagan@virtuozzo.com \
    --cc=rkrcmar@redhat.com \
    --cc=sthemmin@microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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