Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3763765imu; Fri, 30 Nov 2018 05:45:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/VBOom6fLwmXBWWbT0g4Jfr6VtgJ3NHSrfh4dmR6RXz20zXtvONkMqh47RqmADjkDSG7I29 X-Received: by 2002:a63:451a:: with SMTP id s26mr4967293pga.150.1543585559698; Fri, 30 Nov 2018 05:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543585559; cv=none; d=google.com; s=arc-20160816; b=w2l27NCzFIvjBurUYtM7YPOCh6xLUmls0otW6JTtIeH8i63mgP37BFIu16Z12iDimN LILcdGehlDuwc3Q0h/tessSb7hVIqyINnxEKH6Djbxy/BpKlIwuWlySHN19j70aJJZA3 lnTmjZfX2If9O+pmlTS0yOLPvgEnd3q5iokIPx7TgANae/7MxppdUm9gj3LvyHlr2ZWS Zo1BMkTJS5FC/uKZ8lmofuvDKsdT/+P+a0XLL1kKotvpAzlle+LvTf++PntXPd7VC+3h 90ONXSAnrNhStO/YVRgKfvGT2a6M7wWQB3e6JGtj1k3qXIWtRPkUKEtZZc83Q94N+dv2 VjOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=M+VT88FUCRNYqyBbB8NgRNKBEMbOgSs+YZZfnRjok60=; b=fRB0Ab/Ne590g+Y7c7dehr5LE4hLYYaBSiU33ZAL+53jRmuwF/acnYatLVr5W9J1mX 70W5RA/TnuNY38AQR5E9qNhG7XPFJ4IpH6mDqLVXEJ/6Lj+8++46Nl/KKPAuEt6Bkymt 2T/K16G6CTz++yBh8oh/oM3R9f6hnXsipyWY2nTgzsb4vV5xNXplziJQ8oOt3dmO/sB9 9icHyLKKOOpv3+TWHDCcuShr1xj0Of7GNGaGxPHO7tKwisQw2QKh92habNrmMjWSfRvs 9wfbUYCthxzBl3T/yO1p/Hiz3SICleJ/fVdUJbLoBxQp8UO2IshKHJy2091giwCfLRc4 LIvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si5288534plx.383.2018.11.30.05.45.45; Fri, 30 Nov 2018 05:45:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbeLAAy1 (ORCPT + 99 others); Fri, 30 Nov 2018 19:54:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36512 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbeLAAy1 (ORCPT ); Fri, 30 Nov 2018 19:54:27 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70F173154849; Fri, 30 Nov 2018 13:45:06 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 54498165FA; Fri, 30 Nov 2018 13:44:56 +0000 (UTC) From: Vitaly Kuznetsov To: Roman Kagan Cc: "kvm\@vger.kernel.org" , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , "linux-kernel\@vger.kernel.org" , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "x86\@kernel.org" , "Michael Kelley \(EOSG\)" , Nadav Amit , Thomas Gleixner Subject: Re: [PATCH] x86/hyper-v: define structures from TLFS as packed In-Reply-To: <20181130131122.GA2358@rkaganb.sw.ru> References: <20181130121511.12331-1-vkuznets@redhat.com> <20181130131122.GA2358@rkaganb.sw.ru> Date: Fri, 30 Nov 2018 14:44:54 +0100 Message-ID: <87va4ewug9.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 30 Nov 2018 13:45:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Roman Kagan 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