Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1007157rwb; Fri, 13 Jan 2023 06:54:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXUeUPEtOAbTzwKwKUYNlFOFGBpnNDiB6clzyHZypy4nQvalB4XQzVi3RuV1nmYFktQ3/h X-Received: by 2002:a17:903:555:b0:194:6110:9fe1 with SMTP id jo21-20020a170903055500b0019461109fe1mr5432509plb.4.1673621646449; Fri, 13 Jan 2023 06:54:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673621646; cv=none; d=google.com; s=arc-20160816; b=FXCmQSXaTamZU1qkoOhIUrGQZg+JdO4F4+85JzWEPBBM0xg2sQtJ/0CwZVgW7UVjwZ 0383Q8OP/I09U9GPkOqqlIsEglePKu//CLC6yFoG2/ncZSNwk1Ha6M8v3HKo1KD7uy6i Fmm9B5fGf1wnDVXUEsxQfS4Vvag94leu2O/ibFTlrUuTRi7xqgXWEA8cCJ8PWsa2Fu6t Pe3TDgY0sCpim+SmiqK1Edy1KAWL/5ms81/haJ6BV+jWkcRN/4J8BbBZHVeBWUHK8KmP oPhcktbvBLe76tNKqxkMCSXRlCEb/Q3XQGlMxSHWEOKs9lz3kTu/4G8ubxlLzMY8hKVQ Km2w== 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=Tupfp8exSpQ4RbZCFKZqWdQOqhq4P6GGAsJ+a2D0UiA=; b=Z4CoFL54EzxxdCmOQeBBkgflDcAlwuByegxlblEFdijcpQVtFkFZ7iqjKn9aBUK2/4 i6OWyKlgztVlR0Ai6MaWs2h02BqCIwlFqLd+Ul1crhEcHOwZbhs7sbOLR/3ti0wD9f4A UhnndZIok7COs6N7xE281rGhtzAxOaXl5+8pdg7VSDbkmI1cxkQtq1n5Rg0Fur5SY+mD hjwNRalrjvwBzZ4YWVFue0EKDqfkGS4GjjxnMYuFzcKzIi7ErcUUH4/xAaYaySYrPW4F 52iJ7uKPZC3/4LuUQNcQijxc5PBNxYk8yPZfUKkUrCoQsUM+uPvz3RF7710QzPskrFT1 B73Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ez7twyV8; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a17090270ca00b0019329cd26dcsi15270617plt.442.2023.01.13.06.53.45; Fri, 13 Jan 2023 06:54:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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=@alien8.de header.s=dkim header.b=ez7twyV8; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbjAMOp3 (ORCPT + 99 others); Fri, 13 Jan 2023 09:45:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbjAMOpA (ORCPT ); Fri, 13 Jan 2023 09:45:00 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637B99B285; Fri, 13 Jan 2023 06:34:39 -0800 (PST) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id DFD041EC06EE; Fri, 13 Jan 2023 15:34:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1673620476; 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:in-reply-to:in-reply-to: references:references; bh=Tupfp8exSpQ4RbZCFKZqWdQOqhq4P6GGAsJ+a2D0UiA=; b=ez7twyV8r/e81WS/tbD53J8+AErW3z0qB4278JGKImv1VqOOCl1mPfVpOFxrRJ28COpxQh Dv1Gq7oYynLuj2xK9oaktn6HgMReadvqdPvF6eFjiLTcuQhSsMnFEKro/KuoY1OpfH1HFh wAglyU90GKfDGW7vcQmeT3ce5DqinWQ= Date: Fri, 13 Jan 2023 15:34:36 +0100 From: Borislav Petkov To: Michael Roth Cc: 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, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.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, 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, dgilbert@redhat.com, jarkko@kernel.org, ashish.kalra@amd.com, harald@profian.com Subject: Re: [PATCH RFC v7 04/64] KVM: x86: Add 'fault_is_private' x86 op Message-ID: References: <20221214194056.161492-1-michael.roth@amd.com> <20221214194056.161492-5-michael.roth@amd.com> <20230105024256.ptujtjgzcdmpakoa@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230105024256.ptujtjgzcdmpakoa@amd.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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-crypto@vger.kernel.org On Wed, Jan 04, 2023 at 08:42:56PM -0600, Michael Roth wrote: > Obviously I need to add some proper documentation for this, but a 1 > return basically means 'private_fault' pass-by-ref arg has been set > with the appropriate value, whereas 0 means "there's no platform-specific > handling for this, so if you have some generic way to determine this > then use that instead". Still binary, tho, and can be bool, right? I.e., you can just as well do: if (static_call(kvm_x86_fault_is_private)(kvm, gpa, err, &private_fault)) goto out; at the call site. > This is mainly to handle CONFIG_HAVE_KVM_PRIVATE_MEM_TESTING, which > just parrots whatever kvm_mem_is_private() returns to support running > KVM selftests without needed hardware/platform support. If we don't > take care to skip this check where the above fault_is_private() hook > returns 1, then it ends up breaking SNP in cases where the kernel has > been compiled with CONFIG_HAVE_KVM_PRIVATE_MEM_TESTING, since SNP > relies on the page fault flags to make this determination, not > kvm_mem_is_private(), which normally only tracks the memory attributes > set by userspace via KVM_SET_MEMORY_ATTRIBUTES ioctl. Some of that explanation belongs into the commit message, which is a bit lacking... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette