Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp445423pxw; Fri, 8 Apr 2022 11:24:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzScGKwVkqeZ7hX9OBVAhHZshCNfXetxh7ehNgRKwB5+tMfwLqaJK/q93Rcz3w6djOPopCn X-Received: by 2002:a17:902:e882:b0:154:445d:9818 with SMTP id w2-20020a170902e88200b00154445d9818mr20656683plg.40.1649442261196; Fri, 08 Apr 2022 11:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649442261; cv=none; d=google.com; s=arc-20160816; b=JUlSoJSKb6BCAglOMa/bFtKYRbn3rRxZG9Hh8ybno2kBc9D/h7JegfJHaoD9SNrLJ+ t3ikgrmpzGLeGc15uc4X4D8n1Vmbye1oat/9Z/ALNf4H2VMFJCe63Ew37+MaS5At8xne uQyO2HGfqFYzT2rBS4d2CjDg8x6Ev1SOTnEonOJYWx9UQYFvCRYJfasRe19UnR9R3xEr 52tS8uP7+nEiiWF0TMQPKa1OtcvfvgCZCUgj7+FQhVdQUL1P47w5I1exXiQNCFt+cIre 6LhVrEKS268rrNEalqdlVq4s8Coz/wmRzr8RrbAMOIi+zucuoMyFGYQv1FD4Eum3j55B 6gWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=uOqUilg6tFyX4vRcuZ2UavRfBhs/RsVfCBCNRu/MwrA=; b=HDd2aNz5pZysmTYwpO9k7tqQh0OkhL4U5WpLRh7RdUflolE8bbcKHH7IHTGNeV0Gex nVAIYK4XnhmGyqjTMrJOctQvr3D6+mqHz3NM3AkRH2F02exc2UwSnYRlgm2sbM96yMK7 2e93ypmjzYi/123C0VSkLhOj0Dc+B5oU1czIoO9RiMngWUyXEZIHpJnP2pzcPOsfgCGR QHWzkO2u8X29BkgG+ilvFq9yI0Co5fs9TW6BdlAiQ5GO13n+LrecbnrN3ARZYYzvgvnz LfMR6ZuCu17tL+06VmU1ELkvySNeXLMkAdz8f0askaOCVU47yz/g70YMZGS+hcHgBafQ Eyvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kySoZJo2; dkim=neutral (no key) header.i=@linutronix.de header.b=8PpysUvG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t19-20020a63d253000000b003816043ee9dsi2006194pgi.146.2022.04.08.11.24.06; Fri, 08 Apr 2022 11:24:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kySoZJo2; dkim=neutral (no key) header.i=@linutronix.de header.b=8PpysUvG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233546AbiDHJRM (ORCPT + 99 others); Fri, 8 Apr 2022 05:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231335AbiDHJMM (ORCPT ); Fri, 8 Apr 2022 05:12:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E300824BD63; Fri, 8 Apr 2022 02:09:19 -0700 (PDT) Date: Fri, 08 Apr 2022 09:09:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649408958; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uOqUilg6tFyX4vRcuZ2UavRfBhs/RsVfCBCNRu/MwrA=; b=kySoZJo2GsyVqTqZzOuUSbrMj7coDYlLzyzhm7bSXv9kqMVAGkODBvb6JyMmryKlt7bhM8 F650uJr4gJOHFxPS19cTQ7BLHG7AUGjYFn5E3I3oi9B3i/uZx8QPiv6IIyc4f4kC+71Tg+ cx71vvlK4g9sXywhtcifC/6K3k0WD9DmyvkyEz9vUtMKGA16ZslQ2OjvLWUddjnZiPUqNK wKnHV+zmbsaad+aAiI8j298T8VQpsTjVQutmlQglgnnb6dRrCHr1pyAZ2qX/qyhFa+k767 M2O5FuXymqOwag8KXEPHPEH1DN9VcMpC6L+rTtqpwSWYTPmPC1RKc3HIWhx67w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649408958; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uOqUilg6tFyX4vRcuZ2UavRfBhs/RsVfCBCNRu/MwrA=; b=8PpysUvGRsbErlXMxzr9SZSnctpa9uj9hy3YImFdT4QCySNQsKQEG/sJRxhRlT6gR8mMnP P8xLJKDSikpPkJDw== From: "tip-bot2 for Tom Lendacky" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] KVM: SVM: Create a separate mapping for the GHCB save area Cc: Tom Lendacky , Brijesh Singh , Borislav Petkov , Venu Busireddy , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220307213356.2797205-4-brijesh.singh@amd.com> References: <20220307213356.2797205-4-brijesh.singh@amd.com> MIME-Version: 1.0 Message-ID: <164940895699.389.12284453023140266285.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/sev branch of tip: Commit-ID: a4690359eaec985a1351786da887df1ba92440a0 Gitweb: https://git.kernel.org/tip/a4690359eaec985a1351786da887df1ba92440a0 Author: Tom Lendacky AuthorDate: Mon, 07 Mar 2022 15:33:13 -06:00 Committer: Borislav Petkov CommitterDate: Wed, 06 Apr 2022 12:13:34 +02:00 KVM: SVM: Create a separate mapping for the GHCB save area The initial implementation of the GHCB spec was based on trying to keep the register state offsets the same relative to the VM save area. However, the save area for SEV-ES has changed within the hardware causing the relation between the SEV-ES save area to change relative to the GHCB save area. This is the second step in defining the multiple save areas to keep them separate and ensuring proper operation amongst the different types of guests. Create a GHCB save area that matches the GHCB specification. Signed-off-by: Tom Lendacky Signed-off-by: Brijesh Singh Signed-off-by: Borislav Petkov Reviewed-by: Venu Busireddy Link: https://lore.kernel.org/r/20220307213356.2797205-4-brijesh.singh@amd.com --- arch/x86/include/asm/svm.h | 48 ++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 788a43f..0789ad8 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -398,11 +398,51 @@ struct sev_es_save_area { u64 x87_state_gpa; } __packed; +struct ghcb_save_area { + u8 reserved_1[203]; + u8 cpl; + u8 reserved_2[116]; + u64 xss; + u8 reserved_3[24]; + u64 dr7; + u8 reserved_4[16]; + u64 rip; + u8 reserved_5[88]; + u64 rsp; + u8 reserved_6[24]; + u64 rax; + u8 reserved_7[264]; + u64 rcx; + u64 rdx; + u64 rbx; + u8 reserved_8[8]; + u64 rbp; + u64 rsi; + u64 rdi; + u64 r8; + u64 r9; + u64 r10; + u64 r11; + u64 r12; + u64 r13; + u64 r14; + u64 r15; + u8 reserved_9[16]; + u64 sw_exit_code; + u64 sw_exit_info_1; + u64 sw_exit_info_2; + u64 sw_scratch; + u8 reserved_10[56]; + u64 xcr0; + u8 valid_bitmap[16]; + u64 x87_state_gpa; +} __packed; + #define GHCB_SHARED_BUF_SIZE 2032 struct ghcb { - struct sev_es_save_area save; - u8 reserved_save[2048 - sizeof(struct sev_es_save_area)]; + struct ghcb_save_area save; + u8 reserved_save[2048 - sizeof(struct ghcb_save_area)]; u8 shared_buffer[GHCB_SHARED_BUF_SIZE]; @@ -413,6 +453,7 @@ struct ghcb { #define EXPECTED_VMCB_SAVE_AREA_SIZE 740 +#define EXPECTED_GHCB_SAVE_AREA_SIZE 1032 #define EXPECTED_SEV_ES_SAVE_AREA_SIZE 1032 #define EXPECTED_VMCB_CONTROL_AREA_SIZE 1024 #define EXPECTED_GHCB_SIZE PAGE_SIZE @@ -420,6 +461,7 @@ struct ghcb { static inline void __unused_size_checks(void) { BUILD_BUG_ON(sizeof(struct vmcb_save_area) != EXPECTED_VMCB_SAVE_AREA_SIZE); + BUILD_BUG_ON(sizeof(struct ghcb_save_area) != EXPECTED_GHCB_SAVE_AREA_SIZE); BUILD_BUG_ON(sizeof(struct sev_es_save_area) != EXPECTED_SEV_ES_SAVE_AREA_SIZE); BUILD_BUG_ON(sizeof(struct vmcb_control_area) != EXPECTED_VMCB_CONTROL_AREA_SIZE); BUILD_BUG_ON(sizeof(struct ghcb) != EXPECTED_GHCB_SIZE); @@ -490,7 +532,7 @@ struct vmcb { /* GHCB Accessor functions */ #define GHCB_BITMAP_IDX(field) \ - (offsetof(struct sev_es_save_area, field) / sizeof(u64)) + (offsetof(struct ghcb_save_area, field) / sizeof(u64)) #define DEFINE_GHCB_ACCESSORS(field) \ static inline bool ghcb_##field##_is_valid(const struct ghcb *ghcb) \