Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1498129rbb; Mon, 26 Feb 2024 11:06:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXGm3avGsPnPh0uLwLROUI6jEFOfWK0DoWRQ1G6coni6hxtAug5Rk1A+Fngkuyz9jcYLVNg83TEsd/k2yf22JfidfU7GPk84kweaYQQqg== X-Google-Smtp-Source: AGHT+IGHyjQrTAFZ4O966bT539e4qde5ykEynpx6MjdUYWXqFH4lYzzsuxviqG5HqmS+pHRpDnk7 X-Received: by 2002:a05:6a20:9e4b:b0:1a0:ef1e:a5a7 with SMTP id mt11-20020a056a209e4b00b001a0ef1ea5a7mr87303pzb.4.1708974396524; Mon, 26 Feb 2024 11:06:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708974396; cv=pass; d=google.com; s=arc-20160816; b=DdPgAH+a+EOgmhYGneqZHUrEdgo9WCi66W+FpfAE4ollzZ4bmVSOUavzszcfTTkdvm Lpyof9X/z1FGd7ybEIQ7rcEmKbzJJCe1gUak73ldmW3ohgvLrEx6Ez6if0nqeq9EbWlY e3S6IKgnbTGxUrRtN9HiHON4NsFNN5wpL5gSEpq6e9lPb0witSzYoYfw/75+BkkX0nr2 9rwERxsqpIUiM/dIS60adNojToVjcqLzPyakQjG3RV6WN2oPoslo/bjKsjKh10bamzu/ TAXcfL8HKj8sBRnUfgrQrAKKAhHAqF+D9Gr0wZessBYDlRpO5JsRW/gzB8k4bbo+c5Y+ f9bA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7fRP/l4ehwN5ICk87a5/9ybtOo+Pl5c8O/deIJ0OHBM=; fh=TLdZJsFzSA0fpm6Q4iUv+uB0sG0oU+h3Bp6HiSGyZm8=; b=N7bTXlPEFqFCei3eT09JqsRXzVrbJb0P+m2JOWYMSrAqIGlz3n04/JKp58XH54AgZ4 fvuelsMSdgL5ZlL4GUOVx9a78UZ3xk13uYC00A2Q4Lj6wY2QFQ6k87fd7ToUf+qRoYsZ +F88Us6irEm2R9q37pTZssn0JobjHFF2n9K/HowV4dETDo2H/xvqcjErD44r/9kT/sLs V97N1zD2cXW9GTdt2tJyhpnjvmVgpgueBjECuMPr+lRJU4BY53EH9X8XDQ2OwT99a96D lwKYPwYQBpyvxwEeROemqxqurySNeRdE1BeHKwDyJjJ9t40rt3x8qyZXPnaAV4SrEZO7 AxeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RCjfq8Da; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82189-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9-20020a631d09000000b005e27218564asi4152026pgd.157.2024.02.26.11.06.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 11:06:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82189-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RCjfq8Da; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82189-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 385752844B9 for ; Mon, 26 Feb 2024 19:06:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 852BF13249D; Mon, 26 Feb 2024 19:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RCjfq8Da" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4007F130AC0 for ; Mon, 26 Feb 2024 19:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708974236; cv=none; b=VXNlsTR/72wazKNdNxqzGky0iVTcTfT3vkjiYO2KizWCW2EoKsxy5LVVox1bqpFAjHTxbGIjo1FkhsIB2WkgFtNAkhUNgcSDnwAKGECZeA73kfgaQbR6mASVj44Y1YMDSLAMOx9VSqau0d7pwtuqMxns94P0epXQsEIpUvUYPN8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708974236; c=relaxed/simple; bh=8VFZJ7mBeFkFJM3OtDw+ZbNYCfcWygjdv2FVwNhWvGg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=iV9bVvcuFhM1K5vrB5cPl7Srle5bCQ2Yw5hLfKAldVH07SFqsvkW6Y/M028387y5xzzMxPf1+EUo7Z1LguRmDdF9jHvKliC0Rz8C/B+5IWpHJ/8Lxitc+K0GxMLfCvF8UzRvMxcxMUvxBEyT6IP18ZYInHeqOMvxdS4nRIooxME= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RCjfq8Da; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708974232; h=from:from: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=7fRP/l4ehwN5ICk87a5/9ybtOo+Pl5c8O/deIJ0OHBM=; b=RCjfq8DaWdprkXGxg+JaA5EDpVqY6U3LALF/nTDy6vyMg+3AirVJmEKynAgHdRDt01QJOR JeEDb89I9/B3NLjwcToycuExZIRqUmmNWu6aXx26DoDoWjkbR9ZVz90SMcsujxgDJOe2fg GNczDqbFsKH5AoB5lYdWbH8QSj6KYnM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-ykJPlzMQMTqbCiRyKDkhYA-1; Mon, 26 Feb 2024 14:03:48 -0500 X-MC-Unique: ykJPlzMQMTqbCiRyKDkhYA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2AF7A8F7769; Mon, 26 Feb 2024 19:03:48 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 057F9400D784; Mon, 26 Feb 2024 19:03:48 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, michael.roth@amd.com, aik@amd.com Subject: [PATCH v3 12/15] KVM: SEV: introduce to_kvm_sev_info Date: Mon, 26 Feb 2024 14:03:41 -0500 Message-Id: <20240226190344.787149-13-pbonzini@redhat.com> In-Reply-To: <20240226190344.787149-1-pbonzini@redhat.com> References: <20240226190344.787149-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Suggested-by: Sean Christopherson Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/sev.c | 4 ++-- arch/x86/kvm/svm/svm.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 2db0b2b36120..2549a539a686 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -93,7 +93,7 @@ static int sev_flush_asids(unsigned int min_asid, unsigned int max_asid) static inline bool is_mirroring_enc_context(struct kvm *kvm) { - return !!to_kvm_svm(kvm)->sev_info.enc_context_owner; + return !!to_kvm_sev_info(kvm)->enc_context_owner; } static bool sev_vcpu_has_debug_swap(struct vcpu_svm *svm) @@ -644,7 +644,7 @@ static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu, clflush_cache_range(svm->sev_es.vmsa, PAGE_SIZE); vmsa.reserved = 0; - vmsa.handle = to_kvm_svm(kvm)->sev_info.handle; + vmsa.handle = to_kvm_sev_info(kvm)->handle; vmsa.address = __sme_pa(svm->sev_es.vmsa); vmsa.len = PAGE_SIZE; ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_VMSA, &vmsa, error); diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index d6147ad18571..ebf2160bf0c6 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -319,6 +319,11 @@ static __always_inline struct kvm_svm *to_kvm_svm(struct kvm *kvm) return container_of(kvm, struct kvm_svm, kvm); } +static __always_inline struct kvm_sev_info *to_kvm_sev_info(struct kvm *kvm) +{ + return &to_kvm_svm(kvm)->sev_info; +} + static __always_inline bool sev_guest(struct kvm *kvm) { #ifdef CONFIG_KVM_AMD_SEV -- 2.39.1