Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp857908pxj; Fri, 21 May 2021 00:19:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymyJl3g7jBGAmbpsxHIv2IcsPHumBLbUI9Ku9g4Uhay47LjNzx8qGVTUTFS4L683xuDPH5 X-Received: by 2002:a17:906:fc4:: with SMTP id c4mr9340383ejk.111.1621581560817; Fri, 21 May 2021 00:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621581560; cv=none; d=google.com; s=arc-20160816; b=MOoErnGTPkyUSPdrfAbJGNkpigeiOpVUUfFmA9BdXnrcv8dkY8VXFe/QG9Fglr2eZn gAHuG/IM3zwOV7nXqPFtiqypYFO7rrVaRhfOmKTXWxu6kkf0DmoVqtc9oN0LiNZXPWCN kEl1gmMtzqhr5Osr0+l2YeLhs5jIkgkKEwL8YlqBfLq6pGleVyef4kilaN3qyvrXRB4g GsX1byUITXxXd20z1rfJ1sMoeVtQt6xTbpts75fpCgY2uAmEAIbA4ohlYUOfO93aZaCP gDpPT2iYoL+Kskz0LI2yF2rHTfw8xgQe5Eug0XrBe6xmaUFaYv6reDU9ZMudvrspRnFW a4hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iml5vlQyJ5aEreLAznsInz2oxovRQjUf93YcskiYZ98=; b=J0RhV9qCbSW+kjo3uijE5ZH6dikxUG+o+vTCOs5qbQJK6ZzNQcCUdnlvKG3JIc6ef6 5XWFKRwmE9JPJSMh2DtBTrc3B8HCrLuIm034HhrQ1JFqQDRjCSAUBUPRSypQ3XAWz8mN bdqB2m5oXSy7dYbDOzogjMu7h+a4TqR/rj5n6AKLnC9IyluU4pJBaoSn4APYtQX8IHAM +Z3Hks9TjT2xIG7ocC/+gU4GYjwnt7GxbBxmrM4YMdp6ae0ht+9HO5wFSuy+MFbplWVe 4Kil6IJ4J+OlQhW1E3tomfpGkMoLNMT/Al5/DmQ9nDfDqTCfNrQWG82Vpa0ULOOWtDVB IBMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ccjt6etn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si1927768edr.609.2021.05.21.00.18.57; Fri, 21 May 2021 00:19:20 -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=@google.com header.s=20161025 header.b=Ccjt6etn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238832AbhETT27 (ORCPT + 99 others); Thu, 20 May 2021 15:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238217AbhETT26 (ORCPT ); Thu, 20 May 2021 15:28:58 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E637FC061761 for ; Thu, 20 May 2021 12:27:36 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id z4so7486135plg.8 for ; Thu, 20 May 2021 12:27:36 -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=iml5vlQyJ5aEreLAznsInz2oxovRQjUf93YcskiYZ98=; b=Ccjt6etnJXJ4WcP01qXkL2lfD/cv42N3HR1qjpYZw8PuN6vMin+IjrlHmSqms17p6/ xwXuXDA1nj/LcWD8zfKNtYQhQB7kBc9BHoI9WRdweuRJSYIrxAezJWHEIEchkl/quhvO uCs5SqY8laivgv3a/6KDrvx9Wjcc/wmt8XRPsM/1c9ow0WzZreh0xR5JiW3fYwcfSnv0 J01AGvDDic4e0oIxKgv8odZ/Swug+TnG6nHy84dInVlHh/488bxQ5tCwu5k9JEJG+ZzR moCak2rvvXvH8DTTaYPFlAe1LNrDUtMInUHUp6eJL34qHehnJvcMTpyD24Pb/Q9y8Ya0 u87Q== 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=iml5vlQyJ5aEreLAznsInz2oxovRQjUf93YcskiYZ98=; b=nhBrudkJk3WKah/rNstRZSfu9mk3Aq2YQ9CU2jXMIhYmQp7nA8OR18jeBVEytwssp5 KOOupj7+JtpO0/jJcNfjElVdpdE/A9Fb7F2ciuaQVM13suoUNvYc76L8FDEKFDgmKesP j1OuniFoGyZqYyVr/wI2ym8/r2CGHGh5w2LL/1coUzBM1ttJwA4EBdiddrUPqwFKWd2t EeK1YiEMADSYP/XwjRII5INMZDgh4RqQ+Thm8govs4LpARjEVuyBTIvT1PwuvoWG8Vmy NZ4Lgt8zIhVI9tZWqBroErmVpQXdaEQNYUUeDX3W4qfAr11K8F4ck5/IhBhnUm29XiYL tFMw== X-Gm-Message-State: AOAM530+bsgtoMn7qeB3sBpOGWjWTZuKJUvL/Xoq5rwcWFmvGd2uy7dR //45lJdG77MOLa0PIAY50rCjow== X-Received: by 2002:a17:90a:7e03:: with SMTP id i3mr4949220pjl.197.1621538856218; Thu, 20 May 2021 12:27:36 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id w125sm2495213pfw.214.2021.05.20.12.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 12:27:35 -0700 (PDT) Date: Thu, 20 May 2021 19:27:31 +0000 From: Sean Christopherson To: Tom Lendacky Cc: Peter Gonda , kvm list , linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini , Jim Mattson , Joerg Roedel , Vitaly Kuznetsov , Wanpeng Li , Borislav Petkov , Ingo Molnar , Thomas Gleixner , Brijesh Singh Subject: Re: [PATCH] KVM: SVM: Do not terminate SEV-ES guests on GHCB validation failure Message-ID: References: <324d9228-03e9-0fe2-59c0-5e41e449211b@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 20, 2021, Sean Christopherson wrote: > On Mon, May 17, 2021, Tom Lendacky wrote: > > On 5/14/21 6:06 PM, Peter Gonda wrote: > > > On Fri, May 14, 2021 at 1:22 PM Tom Lendacky wrote: > > >> > > >> Currently, an SEV-ES guest is terminated if the validation of the VMGEXIT > > >> exit code and parameters fail. Since the VMGEXIT instruction can be issued > > >> from userspace, even though userspace (likely) can't update the GHCB, > > >> don't allow userspace to be able to kill the guest. > > >> > > >> Return a #GP request through the GHCB when validation fails, rather than > > >> terminating the guest. > > > > > > Is this a gap in the spec? I don't see anything that details what > > > should happen if the correct fields for NAE are not set in the first > > > couple paragraphs of section 4 'GHCB Protocol'. > > > > No, I don't think the spec needs to spell out everything like this. The > > hypervisor is free to determine its course of action in this case. > > The hypervisor can decide whether to inject/return an error or kill the guest, > but what errors can be returned and how they're returned absolutely needs to be > ABI between guest and host, and to make the ABI vendor agnostic the GHCB spec > is the logical place to define said ABI. > > For example, "injecting" #GP if the guest botched the GHCB on #VMGEXIT(CPUID) is > completely nonsensical. As is, a Linux guest appears to blindly forward the #GP, > which means if something does go awry KVM has just made debugging the guest that > much harder, e.g. imagine the confusion that will ensue if the end result is a > SIGBUS to userspace on CPUID. > > There needs to be an explicit error code for "you gave me bad data", otherwise > we're signing ourselves up for future pain. More concretely, I think the best course of action is to define a new return code in SW_EXITINFO1[31:0], e.g. '2', with additional information in SW_EXITINFO2. In theory, an old-but-sane guest will interpret the unexpected return code as fatal to whatever triggered the #VMGEXIT, e.g. SIGBUS to userspace. Unfortunately Linux isn't sane because sev_es_ghcb_hv_call() assumes any non-'1' result means success, but that's trivial to fix and IMO should be fixed irrespective of where this goes.