From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4244A4419 for ; Thu, 19 Oct 2023 14:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HN/xDPc/" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d9a5a16fa94so785900276.0 for ; Thu, 19 Oct 2023 07:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697727477; x=1698332277; darn=lists.linux.dev; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NoyDzNpmGMgG5vgnElNw+7wjvKQootkU5+NZTuzV+xg=; b=HN/xDPc/4NSIclv0nb6pAt6UvwGtn3rm7yxqCCCLDNE117BADZgol3tvVXjyJhJR2M nDN/2+AAZgUkPGODICibWdTAdW25sbgebXjv6KEEe29WR1vHkjGZyssqMoOW5dRogCXD YPVuH0bL0JrBrGjUxoR13V8CMYeI+B6pM1pUG1SflWPH9lYQR+dVG6G2aRpLjuvichHl VAW0I4jVodVB3q9RIQ6591KJVInr/zO8HhaQCGoVyoCH3XivPkMyUXsSJzmZq43vmibg HEJlvZrRi1gaxIlg9qPFQXH/lFEclmIMJiDA+tzfUzYAPrrp8Kxd00PchTZaYAmciQs+ onog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697727477; x=1698332277; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NoyDzNpmGMgG5vgnElNw+7wjvKQootkU5+NZTuzV+xg=; b=kjubzSMV/pqLytBgBDIUjGRvmFceyyNKvLBDHAOEqwKz+W6/OV83lBdH+S6bO4sHKM mwxgXg90h+1UtS3rEVoeSre3KVwz7IcaIqXWnePtKzEYmIO0CdcWkZct9sWa/5Uush2I BwFG0vSuVv8EOQY7j5zryDt2wxaVGcSzavVmZnn9CD7j5Da+CVR5wVLFkz02yruk4Hlm m+A3ixODRQstZ/gPjDc4HKQgxXf7q0yReLEjhdNcCaUy6LxgcQ+aAvQpn6MVa+i7CBwI 9PrVhucIbKL0O8F7a3HB2GNwtcxBYcQJhFdJQ1zcc96u9q1XaKLOtdruf86NNRO/jf3S EOxw== X-Gm-Message-State: AOJu0Yx2jjPR4D+gZHo4slm3LDHlqOh0dLr33MhOtpbhbYs0wawqcl3E 2mIPCohJv6X/keNaCoKHWAJMjg191sg= X-Google-Smtp-Source: AGHT+IGGSi1A+odVH3et/CwWq4QLFvjNrU7TNfsn6fh/fjXnuZNCRYjqcrZpE1GRu0FMfXKhYQGxJgbQ8Z4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1202:b0:d9a:b81b:fd66 with SMTP id s2-20020a056902120200b00d9ab81bfd66mr66949ybu.2.1697727477216; Thu, 19 Oct 2023 07:57:57 -0700 (PDT) Date: Thu, 19 Oct 2023 07:57:55 -0700 In-Reply-To: <924b755a-977a-4476-9525-a7626d728e18@amd.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231016132819.1002933-1-michael.roth@amd.com> <20231016132819.1002933-49-michael.roth@amd.com> <924b755a-977a-4476-9525-a7626d728e18@amd.com> Message-ID: Subject: Re: [PATCH v10 48/50] KVM: SEV: Provide support for SNP_GUEST_REQUEST NAE event From: Sean Christopherson To: Alexey Kardashevskiy Cc: Dionna Amalie Glaze , Michael Roth , kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, jroedel@suse.de, thomas.lendacky@amd.com, hpa@zytor.com, ardb@kernel.org, pbonzini@redhat.com, vkuznets@redhat.com, jmattson@google.com, luto@kernel.org, dave.hansen@linux.intel.com, slp@redhat.com, pgonda@google.com, peterz@infradead.org, srinivas.pandruvada@linux.intel.com, rientjes@google.com, dovmurik@linux.ibm.com, tobin@ibm.com, bp@alien8.de, vbabka@suse.cz, kirill@shutemov.name, ak@linux.intel.com, tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com, alpergun@google.com, jarkko@kernel.org, ashish.kalra@amd.com, nikunj.dadhania@amd.com, pankaj.gupta@amd.com, liam.merwick@oracle.com, zhi.a.wang@intel.com, Brijesh Singh Content-Type: text/plain; charset="us-ascii" On Thu, Oct 19, 2023, Alexey Kardashevskiy wrote: > > On 19/10/23 00:48, Sean Christopherson wrote: > > static int snp_handle_ext_guest_request(struct vcpu_svm *svm) > > { > > struct kvm_vcpu *vcpu = &svm->vcpu; > > struct kvm *kvm = vcpu->kvm; > > struct kvm_sev_info *sev; > > unsigned long exitcode; > > u64 data_gpa; > > > > if (!sev_snp_guest(vcpu->kvm)) { > > ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, SEV_RET_INVALID_GUEST); > > return 1; > > } > > > > data_gpa = vcpu->arch.regs[VCPU_REGS_RAX]; > > if (!IS_ALIGNED(data_gpa, PAGE_SIZE)) { > > ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, SEV_RET_INVALID_ADDRESS); > > return 1; > > } > > > > vcpu->run->hypercall.nr = KVM_HC_SNP_GET_CERTS; > > vcpu->run->hypercall.args[0] = data_gpa; > > vcpu->run->hypercall.args[1] = vcpu->arch.regs[VCPU_REGS_RBX]; > > vcpu->run->hypercall.flags = KVM_EXIT_HYPERCALL_LONG_MODE; > > btw why is it _LONG_MODE and not just _64? :) I'm pretty sure it got copied from Xen when KVM started adding supporting for emulating Xen's hypercalls. I assume Xen PV actually has a need for identifying long mode as opposed to just 64-bit mode, but KVM, not so much. > > vcpu->arch.complete_userspace_io = snp_complete_ext_guest_request; > > return 0; > > } > > This should work the KVM stored certs nicely but not for the global certs. > Although I am not all convinced that global certs is all that valuable but I > do not know the history of that, happened before I joined so I let others to > comment on that. Thanks, Aren't the global certs provided by userspace too though? If all certs are ultimately controlled by userspace, I don't see any reason to make the kernel a middle-man.