From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 0B036168 for ; Mon, 19 Jul 2021 20:04:51 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id p17so10213243plf.12 for ; Mon, 19 Jul 2021 13:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6mrIddCBqzP9Q52MJPTxcpi1gB+yoljcisd3OcU3iwY=; b=UWN1mAIBvoS4DLrVaNW+rWGV/OZ2BCPW1+LGCZCkgQnV1zqBepdR60rAsAMa59hVmO nAUA+PfURyO6iS6RnTJ/RAb2NwXk0KVXwdW6NfzkuMsV4Cqx+o0gFm9aqhJKswk+l3nR bNjZdMU+6WNseInEDkXhoGcgSsbVi+7dW6ND228Zz6niJ42x7HaEbUYFZznbuHQ2TRap gb8xMjdUuXKbVf9BD8weBoqPaxhQIyDMb9WWs558ZtLU6bie+ua0+N2mEt2UC4UUjikh UUTmXFdsL7HEujwsHb18XcFjh0PkGuAP9CZjgUN8nmIpuMxfPEwOGH3SSjtoD0x3IvKQ HtVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6mrIddCBqzP9Q52MJPTxcpi1gB+yoljcisd3OcU3iwY=; b=drRWxd4ku4IXItllysnnDcX8qvSTT0vJeqsjBcFVP33lLJJ9xsCwW6kU6ayW6i2fvt Dvcg6h9XqwNaNIfmrHr9F6tu8cwcISMqLeMSY4lKcBlGXXKiaqzr9/Fd7LrRxf/26Z4M IK0ewGKMXCCUnaVtmq5hFotwBEQ6BtAS/0yP/sdtijJIJF5GQWlsYNr8RhowbQ1r9etj eJACTPLbMdvdoUTNQSEEpdBd5xvEdBNpZiQ3wqEBsZQWKhHSpvxR/q51I1GbaaoNZaEZ wogapm03RujuPxW4Q+9Ug/Vcq4/1AaR9TtLspakvfpqv3aB+ha8dxqi55wFJjSxAEyTc Qr/A== X-Gm-Message-State: AOAM5311ZSdy4raghRw+rJvShZEXXjtmWKsOsQPyj8dDaBPvboBrSmEs MwaAGFjbx+Ff1K5yHxjPoCLJ4Q== X-Google-Smtp-Source: ABdhPJyWwkctPggHtVzSznHpuN2o7lMFAaGwb6T+Lhzg1Hc0ZtDLw1R7db1DHG1Rcj+uWzfPnXseTw== X-Received: by 2002:a17:902:bcc3:b029:11c:5ffb:61fb with SMTP id o3-20020a170902bcc3b029011c5ffb61fbmr20657848pls.18.1626725091240; Mon, 19 Jul 2021 13:04:51 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id w5sm21451077pfq.130.2021.07.19.13.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 13:04:50 -0700 (PDT) Date: Mon, 19 Jul 2021 20:04:46 +0000 From: Sean Christopherson To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com Subject: Re: [PATCH Part2 RFC v4 32/40] KVM: SVM: Add support to handle GHCB GPA register VMGEXIT Message-ID: References: <20210707183616.5620-1-brijesh.singh@amd.com> <20210707183616.5620-33-brijesh.singh@amd.com> <35b1c6c6-b8f1-6ec6-e55c-f2e552e29527@amd.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <35b1c6c6-b8f1-6ec6-e55c-f2e552e29527@amd.com> On Fri, Jul 16, 2021, Brijesh Singh wrote: > > On 7/16/21 3:45 PM, Sean Christopherson wrote: > > On Wed, Jul 07, 2021, Brijesh Singh wrote: > >> + /* SEV-SNP guest requires that the GHCB GPA must be registered */ > >> + if (sev_snp_guest(svm->vcpu.kvm) && !ghcb_gpa_is_registered(svm, ghcb_gpa)) { > >> + vcpu_unimpl(&svm->vcpu, "vmgexit: GHCB GPA [%#llx] is not registered.\n", ghcb_gpa); > > I saw this a few other place. vcpu_unimpl() is not the right API. KVM supports > > the guest request, the problem is that the GHCB spec _requires_ KVM to terminate > > the guest in this case. > > What is the preferred method to log it so that someone debugging know > what went wrong. Using the kernel log is probably a bad choice in general for this error. Because this and the other GHCB GPA sanity checks can be triggered from the guest, any kernel logging needs to be ratelimited. Ratelimiting is problematic because it means some errors may not be logged; that's quite unlikely in this case, but it's less than ideal. The other issue is that KVM can't dump the RIP because guest state is encrypted, e.g. KVM can provide the task PID, but that's it. The best solution I can think of at the moment would be some form of KVM_EXIT_INTERNAL_ERROR, i.e. kick out to userspace with a meaningful error code and the bad GPA so that userspace can take action. I believe Jim also has some thoughts on how to improve "logging" of guest errors, but he's on vacation for a few weeks.