Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1687159pxf; Fri, 26 Mar 2021 12:23:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3pBt4KfvnHmtFL2ZJT+yh0a+s6oKa+O9Ctj7LXQpMCiW2Zvlizo8n9Y0/+cTsTGC0zmg6 X-Received: by 2002:a17:907:7683:: with SMTP id jv3mr16848640ejc.450.1616786637143; Fri, 26 Mar 2021 12:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616786637; cv=none; d=google.com; s=arc-20160816; b=GzzefbwsqzLHDBbLWAjL0oPhPQpo8oDuBKhQCNSNFcwU3Vr+U5Bdkw8fBqypSrrxs6 4oycBSz+JPIrXItvyiHf76wEcuLzU6BghPIY64kmUrgBwYjqEL3V/VtxHoWjNyIYyYhA 122Ag+yeDwhy28e4iCjQhnDfl4CgcxPuxHjoF1Oc7m9Mc4VTRWJjU6NOx9YGkY6vNc3e T+rfs6rg1scYBebR0991MkCZeS0t/qzdrV9zof1k1/whzZfTdFfVEseF/oxWa9yVRpQb Dp7HPkZXCSuImxXwsj9IGVTFyoEnh/WflGI9J0o+lEGYyHtgHqS8TV6Vk5gWfMKqW+CJ xvww== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2PK6VlpQ7yr3XeTWBabuXpI2dtKVX7LC4l+bJOdrm2E=; b=0FraJro8MrTAkvtO6K+RDJt/8LLFj4PhWHvx83ZGuupS33F8XK1jCUkLhHJ3+ONSyN 9mc9yZ2zAgotQvVcuzdgZCxEiEcJ1naFRjh+RKxBqbN8W/HG65696Np6iEgQ6BHVv5K+ SDM6kMvz+c5NL+5WsG5eSMAC1surlX9svtFJS2jFILwE4tBY+qi0fO/fgwyxl2/d3exq 0y7iTrHSIdphpvhy0j609Q0G96j1aOMCEfRMEh1JW/KkIEOpc4mLWaBZ2F8Om7R9ocVg 2hAJMoKc51l0LBnFwo0U7Z1+nK0HXjrff4fyJTWfXhos7hvvZsmLKTZveBY76y5vyqkv mL1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=PqW4Sb8l; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p22si7466677ejm.148.2021.03.26.12.23.34; Fri, 26 Mar 2021 12:23:57 -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=@alien8.de header.s=dkim header.b=PqW4Sb8l; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230195AbhCZTWf (ORCPT + 99 others); Fri, 26 Mar 2021 15:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbhCZTWN (ORCPT ); Fri, 26 Mar 2021 15:22:13 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B9C5C0613AA; Fri, 26 Mar 2021 12:22:13 -0700 (PDT) Received: from zn.tnic (p200300ec2f075f009137b2b45d3c68fe.dip0.t-ipconnect.de [IPv6:2003:ec:2f07:5f00:9137:b2b4:5d3c:68fe]) (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 9D5BD1EC053B; Fri, 26 Mar 2021 20:22:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1616786531; 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=2PK6VlpQ7yr3XeTWBabuXpI2dtKVX7LC4l+bJOdrm2E=; b=PqW4Sb8lMqhsFmDJX1/qoKQJ2Ht2id/fUYuzq7SVcF1zJuYIMepXk0Z1gBGJVTE45kdcec gQhaLj3R+k1Q0mLzEMytfC2GL8aBOdqkiXGdTpPOKDUFg7gWddtzw1bRF11LAxwxrI+x/S F8yd+Fl//rUGXtqxCerzt1fWSh24b1s= Date: Fri, 26 Mar 2021 20:22:14 +0100 From: Borislav Petkov To: Brijesh Singh Cc: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, ak@linux.intel.com, Thomas Gleixner , Ingo Molnar , Joerg Roedel , "H. Peter Anvin" , Tony Luck , Dave Hansen , "Peter Zijlstra (Intel)" , Paolo Bonzini , Tom Lendacky , David Rientjes , Sean Christopherson Subject: Re: [RFC Part1 PATCH 03/13] x86: add a helper routine for the PVALIDATE instruction Message-ID: <20210326192214.GK25229@zn.tnic> References: <20210324164424.28124-1-brijesh.singh@amd.com> <20210324164424.28124-4-brijesh.singh@amd.com> <20210326143026.GB27507@zn.tnic> <9c9773d1-c494-2dfe-cd2a-95e3cfdfa09f@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9c9773d1-c494-2dfe-cd2a-95e3cfdfa09f@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 26, 2021 at 10:42:56AM -0500, Brijesh Singh wrote: > There is no strong reason for a separate sev-snp.h. I will add a > pre-patch to rename sev-es.h to sev.h and add SNP stuff to it. Thx. > I was trying to adhere to existing functions which uses a direct > instruction opcode. That's not really always the case: arch/x86/include/asm/special_insns.h The "__" prefixed things should mean lower abstraction level helpers and we drop the ball on those sometimes. > It's not duplicate error code. The EAX returns an actual error code. The > rFlags contains additional information. We want both the codes available > to the caller so that it can make a proper decision. > > e.g. > > 1. A callers validate an address 0x1000. The instruction validated it > and return success. Your function returns PVALIDATE_SUCCESS. > 2. Caller asked to validate the same address again. The instruction will > return success but since the address was validated before hence > rFlags.CF will be set to indicate that PVALIDATE instruction did not > made any change in the RMP table. Your function returns PVALIDATE_VALIDATED_ALREADY or so. > You are correct that currently I am using only carry flag. So far we > don't need other flags. What do you think about something like this: > > * Add a new user defined error code > >  #define PVALIDATE_FAIL_NOUPDATE        255 /* The error is returned if > rFlags.CF set */ Or that. > * Remove the rFlags parameters from the __pvalidate() Yes, it seems unnecessary at the moment. And I/O function arguments are always yuck. > * Update the __pvalidate to check the rFlags.CF and if set then return > the new user-defined error code. Yap, you can convert all that to pvalidate() return values, methinks, and then make that function simpler for callers because they should not have to deal with rFLAGS - only return values to denote what the function did. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette