Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3153237pxb; Sat, 6 Feb 2021 23:03:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQgfUwnLTmv2yrGxxs947NiZD3SNQwbZ5L9fxEt4/cc/yAUGNJklOOJegSNqjtZo+e2Bfk X-Received: by 2002:a17:906:eb88:: with SMTP id mh8mr11435958ejb.150.1612681387378; Sat, 06 Feb 2021 23:03:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612681387; cv=none; d=google.com; s=arc-20160816; b=vvKGUIw+GRX0lw2I6s11Pm5i33RbMDdxqSUPFnDNxHV4nHuvj2unFU0Bt/gNJhPXS6 N3Wl9zWtBsuxvqPIr+d6cHv2EDnty0RtporbZXDp+ckYOQJm0OIqqTGpOVP5/lwlIgDV LfDv3udvcTPfW7g/2PMs//gk65CuwRnnWuHfl2sfnPOvMeLubg3z1egl/kbOh8VNLPR6 gH/ZPGqEnN/v6lDT/6LO7cWj3ZkWBdubprdIA2gqwIjhCP2Jnv5P9kKZz++dEk6sl+Ei 7OKqN1+ogs9CgDYKFvwyVw6PvMppYGM15dDmUbkS6dMyOW1cbXntk0rtxZ0HbZqk2nZC xhgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=qV6RM27+hBRvUexx7O1HgloIPX/MJTtz3nApakixNtQ=; b=BdkdkyQK5+pD5rgrMMGl3v69GebVtkTjYsJwuWNRquDRkZR7Mu5MpfXp6MLHaZVFT1 HYuIQql8x2/ytGl292xKKKTbHR4jKLwM+gT+B9khzNoOIUlB/ubR9avn5qpPh82evj6m luTfU6AXPM2T/g626hGaoSc5T4buDGeAyhlF7b0nnCLEJs4QiT6rruFGBCpQdcLLQ6Is pE+Hafok0iSTE+41vTd3b4GYWoJ0Vght49FZFB0RGGOyWYjeu+cXq32yES/JdMAKZqe6 jMv/UziNepryWzyFHCokiq7Zt/M/YVTlXFygFI/qV6HGUXt+xOa2pbOGUL703eidixBU ERrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x1si9015016ejw.553.2021.02.06.23.02.37; Sat, 06 Feb 2021 23:03:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbhBGG66 (ORCPT + 99 others); Sun, 7 Feb 2021 01:58:58 -0500 Received: from mga07.intel.com ([134.134.136.100]:48437 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbhBGG56 (ORCPT ); Sun, 7 Feb 2021 01:57:58 -0500 IronPort-SDR: +h3S9nDwxPMzQAgXrVKQMiMBsc2KMniRYA58Mnv64IrM/uKZ2OvFi2QRVtaORnF34J5RVTW4Ml LyVGXg2Ozp/A== X-IronPort-AV: E=McAfee;i="6000,8403,9887"; a="245660854" X-IronPort-AV: E=Sophos;i="5.81,159,1610438400"; d="scan'208";a="245660854" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2021 22:54:52 -0800 IronPort-SDR: iasB+wYl29YDjO5FqNQn3Mb/jN+7veHC66sdj8loc20lAf9zfKbkJjx5vdxCBpDZhLwiSUg7CA 6ENYskT7Yltg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,159,1610438400"; d="scan'208";a="410376599" Received: from vmmteam.bj.intel.com ([10.240.193.86]) by fmsmga004.fm.intel.com with ESMTP; 06 Feb 2021 22:54:51 -0800 From: Jing Liu To: pbonzini@redhat.com, seanjc@google.com, kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jing2.liu@intel.com Subject: [PATCH RFC 5/7] kvm: x86: Revise CPUID.D.1.EBX for alignment rule Date: Sun, 7 Feb 2021 10:42:54 -0500 Message-Id: <20210207154256.52850-6-jing2.liu@linux.intel.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20210207154256.52850-1-jing2.liu@linux.intel.com> References: <20210207154256.52850-1-jing2.liu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CPUID.0xD.1.EBX[1] is set if, when the compacted format of an XSAVE area is used, this extended state component located on the next 64-byte boundary following the preceding state component (otherwise, it is located immediately following the preceding state component). AMX tileconfig and tiledata are the first to use 64B alignment. Revise the runtime cpuid modification for this rule. Signed-off-by: Jing Liu --- arch/x86/kvm/cpuid.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 04a73c395c71..ee1fac0a865e 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -35,12 +35,17 @@ static u32 xstate_required_size(u64 xstate_bv, bool compacted) { int feature_bit = 0; u32 ret = XSAVE_HDR_SIZE + XSAVE_HDR_OFFSET; + bool is_aligned = false; xstate_bv &= XFEATURE_MASK_EXTEND; while (xstate_bv) { if (xstate_bv & 0x1) { u32 eax, ebx, ecx, edx, offset; cpuid_count(0xD, feature_bit, &eax, &ebx, &ecx, &edx); + /* ECX[2]: 64B alignment in compacted form */ + is_aligned = !!(ecx & 2); + if (is_aligned && compacted) + ret = ALIGN(ret, 64); offset = compacted ? ret : ebx; ret = max(ret, offset + eax); } -- 2.18.4