Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp211439pxb; Mon, 25 Oct 2021 06:53:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYIkJiRwAxd4zKpCFpJnYIoLnYVCgObHDkDgbxwsra94Xj7qhVD+PW6zp52BM35OY5N+1q X-Received: by 2002:a17:903:189:b0:140:5f35:437 with SMTP id z9-20020a170903018900b001405f350437mr3367408plg.56.1635170006960; Mon, 25 Oct 2021 06:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635170006; cv=none; d=google.com; s=arc-20160816; b=F9QNI74lQyUW85qbBqQsGmRepGNzLmuH9CXoUoG1ZEb94fGFs7BN/cLK/eRRPOPjBx t536lh8ud1p8ZDDlv4dmF7kiyAoKHYW4X9UOS8+XOFkIFfnuRsUSCKpvXH1NKC+NUpgn /RBitN4xUFVu8woysTjtqqNBuMFHUdxFp04nIdhPbUaY01x2PYIxm9BrXeew6XqBhN8c jSG6gaz8wLEnVL6d4GXPHXmVj0zYuVa3R/nL4dTdfhNE2HRNCRvVBZtJs58nh+iZzXay iKIgjHM+H+L8gkCVCs5uNxqye0J1c31Lu1GSurrT+ehJStI0nW1EdQvwOrQFHbqmkw6u fMBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZdmN+tkx79fwis7eS+XRuIwj8hA3a++/fJHMeaiCPUI=; b=1CFshMZ+ReTpfeF1qL95UJl2KUs40HyGumVxpnomlt17Nr+zowKHK4uOkDRI+oeecT iHi8mZfS3+HTnNP/urduu3Gix0Y+BOQ07Vxqu/7yKQW4ERosbMhKrmbYKv95NVG9XGyC fSxYS7BF4s1bR1OoQ9DXzTsnVk8qS2WXyxaiTXCjE0JGCEuFtggSdr1DL2GTB2oKNmI9 bNwlPhCCmcrFgQ3HWGrkzIsuKcol9e3NEseVChJ/V2xhG42aMltfKlnASsTPjsQ2i01w x0UwX6AiH3U/s99qUZU9XhrYp/FqqudmYglDgqWx6jx91FTaw+a8KXjh/MdoKt8snuLE G2Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LHZfmnqJ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kk11si17814612pjb.149.2021.10.25.06.53.13; Mon, 25 Oct 2021 06:53:26 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LHZfmnqJ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233328AbhJYMYI (ORCPT + 99 others); Mon, 25 Oct 2021 08:24:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233106AbhJYMXp (ORCPT ); Mon, 25 Oct 2021 08:23:45 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E1CC061745; Mon, 25 Oct 2021 05:21:23 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id m26so10590844pff.3; Mon, 25 Oct 2021 05:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZdmN+tkx79fwis7eS+XRuIwj8hA3a++/fJHMeaiCPUI=; b=LHZfmnqJbYkxZqeBLfuMe1x636+SKK8Tw6EC941O8sWLa65vYkRZSLRlS7yLr57Fh0 kFM4e0u0zDGuuDBC888/NS8vKaV7N7YlBYn8nh35+1IgRUKDDEWNv/GdC9VDRX1derN7 OM4OdEuQmJtBOO20tvrn7uYiySCM9ZZFA9gkDEaXDHzML5qHqjecE5p/3842cW5dQhIM VFvx5LY5e2NJiM2adRrl59MkOco195JZj566gdqoPmX6Pji+xze/ipHxlQ179BiEUOJ5 zFTT56MhY/ZXCr3FD/dThiXNRJfdBbcuxiucjoZMQZ5a7UwTkQoBAqvcnIbxCEeFAR1B k6YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZdmN+tkx79fwis7eS+XRuIwj8hA3a++/fJHMeaiCPUI=; b=tDa5TD65v+4OKaxDwjEQThDLf989+lGlycHzEYagy1LW9Dqr1TdDXxjnAmCM2sgTwo U7v6kFK3FNSaDDVjoRFLoszqXHJuS1WUJntJFDOY2mMxvchUqC0fbok1I5ydq/BSkklR KhYYhaZUunDdYQ1a+ELS4cFrPpZrqsBgLBJhppemeDuL+lkDofHg189Ua+yiZYcQV743 v9xgCpHanmhuGxMs1rknIZqfwJ4V0P7vNI6OgAksb+pQ6uDpaohOyM0XIcm9hGodWGtV qV4HXa7QvXniinZNR+EQ2wMY+U4TE4jMzdRS0zODvv6mT8cYJ8BumTGx/4YMZGER803D PUEg== X-Gm-Message-State: AOAM530VJwOiXSVdi3Y5t/h2ZiNLe41Z+Us/aNeuJPxj3WQPiQBv3QF5 VyMEU0y6jzOb+0U5FlO38sA= X-Received: by 2002:a63:334c:: with SMTP id z73mr13566286pgz.160.1635164482577; Mon, 25 Oct 2021 05:21:22 -0700 (PDT) Received: from ubuntu-Virtual-Machine.corp.microsoft.com ([2001:4898:80e8:8:bcf6:9813:137f:2b6]) by smtp.gmail.com with ESMTPSA id mi11sm2786166pjb.5.2021.10.25.05.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 05:21:22 -0700 (PDT) From: Tianyu Lan To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, davem@davemloft.net, kuba@kernel.org, gregkh@linuxfoundation.org, arnd@arndb.de, brijesh.singh@amd.com, jroedel@suse.de, mikelley@microsoft.com, Tianyu.Lan@microsoft.com, thomas.lendacky@amd.com, pgonda@google.com, akpm@linux-foundation.org, rppt@kernel.org, kirill.shutemov@linux.intel.com, saravanand@fb.com, aneesh.kumar@linux.ibm.com, sfr@canb.auug.org.au, david@redhat.com, michael.h.kelley@microsoft.com Cc: linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, vkuznets@redhat.com, konrad.wilk@oracle.com, hch@lst.de, robin.murphy@arm.com, joro@8bytes.org, parri.andrea@gmail.com, dave.hansen@intel.com Subject: [PATCH V9 2/9] x86/hyperv: Initialize shared memory boundary in the Isolation VM. Date: Mon, 25 Oct 2021 08:21:07 -0400 Message-Id: <20211025122116.264793-3-ltykernel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211025122116.264793-1-ltykernel@gmail.com> References: <20211025122116.264793-1-ltykernel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tianyu Lan Hyper-V exposes shared memory boundary via cpuid HYPERV_CPUID_ISOLATION_CONFIG and store it in the shared_gpa_boundary of ms_hyperv struct. This prepares to share memory with host for SNP guest. Reviewed-by: Michael Kelley Signed-off-by: Tianyu Lan --- Change since v4: * Rename reserve field. Change since v3: * user BIT_ULL to get shared_gpa_boundary * Rename field Reserved* to reserved --- arch/x86/kernel/cpu/mshyperv.c | 2 ++ include/asm-generic/mshyperv.h | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index b09ade389040..4794b716ec79 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -313,6 +313,8 @@ static void __init ms_hyperv_init_platform(void) if (ms_hyperv.priv_high & HV_ISOLATION) { ms_hyperv.isolation_config_a = cpuid_eax(HYPERV_CPUID_ISOLATION_CONFIG); ms_hyperv.isolation_config_b = cpuid_ebx(HYPERV_CPUID_ISOLATION_CONFIG); + ms_hyperv.shared_gpa_boundary = + BIT_ULL(ms_hyperv.shared_gpa_boundary_bits); pr_info("Hyper-V: Isolation Config: Group A 0x%x, Group B 0x%x\n", ms_hyperv.isolation_config_a, ms_hyperv.isolation_config_b); diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index 2d88aa855f7e..a8ac497167d2 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -35,7 +35,17 @@ struct ms_hyperv_info { u32 max_vp_index; u32 max_lp_index; u32 isolation_config_a; - u32 isolation_config_b; + union { + u32 isolation_config_b; + struct { + u32 cvm_type : 4; + u32 reserved1 : 1; + u32 shared_gpa_boundary_active : 1; + u32 shared_gpa_boundary_bits : 6; + u32 reserved2 : 20; + }; + }; + u64 shared_gpa_boundary; }; extern struct ms_hyperv_info ms_hyperv; -- 2.25.1