Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1055665pxb; Thu, 15 Apr 2021 12:51:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcAv9PDJo/Sj6jTlx5c864xLxcOWfiqsF/rwXVZHSTm0hvhTqN+WgLHyfiN1Z4vPZCYt+X X-Received: by 2002:a17:907:98ae:: with SMTP id ju14mr5208921ejc.287.1618516295851; Thu, 15 Apr 2021 12:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618516295; cv=none; d=google.com; s=arc-20160816; b=HdhXMvkCWiYvKYpIE6PLSUWDCC7rqzUh+QcHeomn2WGNyWr1LfdHhjcogMeqv7znaR MQG0a/3zoobfjKy+K87t+5i/1CdE/Q8aLSU3SNHs4sWF2KEjodwVox6QZosoJtAINWSh 1hUgUNEMsQzoU1i74IJLXGXK6a8mjtnsDb9MEVB3cJGHO9RXZmJgcjmRdj+tSTVtRnpv Wq4+XB+XtG9zc1rFNAGF/+oAMG6hF9Zu8R4OsHhDoh1ywlg4plnjeAWrJdWfe8di7Wcl QHdGHaLyE0AHBAYI6GiYfpBn2sFaQuh44cNRlSvrUfONFrjQ3jtNX/W0fJ44aARiNkVD htsQ== 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=m+1u7jWekMJzRnPaUKo/hlQMLbQ3pB3EnuCoWlBcJwE=; b=Z0B6pWgNBB9pLdC4UqAgNKFwAuZRuPd+T0SSSJgyLId3GFJPv3CdLw76yZO0dL45/J +ciCDZ4w/bwCyQRV3VuZIHihwI8XmhPHHXY13UDk/m0sAlKwe2OQuyCj9DEFi48kZRRk BXJ9tEuIYYKnbfE5tnmphyfeDiFkooM9ZeaJEqpfiYxex76/aQIhjNkA63yWi3eC5rb9 9/oCb5NGwQeePbyrnBVBE0EiShq260mt5nNPVK4j5udXqkKwog/rs+qxwZCzntbgb/ng Vow2V5ZHk7xp8TxfR8Kf9syaKwLxl7EUHOcS+v1L+XeLOOs0j0PMHfmJLvLF7rPZGWiP 9AIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="gC/HenhF"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f8si3297687edd.395.2021.04.15.12.51.12; Thu, 15 Apr 2021 12:51:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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="gC/HenhF"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 S234959AbhDOTuw (ORCPT + 99 others); Thu, 15 Apr 2021 15:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234226AbhDOTuv (ORCPT ); Thu, 15 Apr 2021 15:50:51 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B28C061574; Thu, 15 Apr 2021 12:50:27 -0700 (PDT) Received: from zn.tnic (p200300ec2f0ace009d15a56636e5abd2.dip0.t-ipconnect.de [IPv6:2003:ec:2f0a:ce00:9d15:a566:36e5:abd2]) (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 063121EC03E4; Thu, 15 Apr 2021 21:50:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1618516226; 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=m+1u7jWekMJzRnPaUKo/hlQMLbQ3pB3EnuCoWlBcJwE=; b=gC/HenhFlKg6OxOBD5VmBJE7r2uQnnyrYhzs7L7smfXhCX62Dm4DyBu8DDw9HPr/dclVF7 tWQhGAdvoTQgF/bnrvyy/Fms2w0qHDXUavv/J2XYx1SjESSCNHXwO0y3Bl6kVdvijQKUWm BZCr/BMY883/B+Eclm1Ezk8MUMmxUgY= Date: Thu, 15 Apr 2021 21:50:20 +0200 From: Borislav Petkov To: Brijesh Singh Cc: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, linux-crypto@vger.kernel.org, ak@linux.intel.com, herbert@gondor.apana.org.au, 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 Part2 PATCH 02/30] x86/sev-snp: add RMP entry lookup helpers Message-ID: <20210415195020.GG6318@zn.tnic> References: <20210324170436.31843-1-brijesh.singh@amd.com> <20210324170436.31843-3-brijesh.singh@amd.com> <20210415165711.GD6318@zn.tnic> <1813139d-f5f9-3791-dadb-4a684fe1cf46@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1813139d-f5f9-3791-dadb-4a684fe1cf46@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Apr 15, 2021 at 01:08:09PM -0500, Brijesh Singh wrote: > This is from Family 19h Model 01h Rev B01. The processor which > introduces the SNP feature. Yes, I have already upload the PPR on the BZ. > > The PPR is also available at AMD: https://www.amd.com/en/support/tech-docs Please add the link in the bugzilla to the comments here - this is the reason why stuff is being uploaded in the first place, because those vendor sites tend to change and those links become stale with time. > I guess I was trying to shorten the name. I am good with struct rmpentry; Yes please - typedefs are used only in very specific cases. > All those magic numbers are documented in the PPR. We use defines - not magic numbers. For example #define RMPTABLE_ENTRIES_OFFSET 0x4000 The 8 is probably PAGE_SHIFT - RMPENTRY_SHIFT because you have GPA bits [50:12] and an RMP entry is 16 bytes, i.e., 1 << 4. With defines it is actually clear what the computation is doing - with naked numbers not really. > APM does not provide the offset of the entry inside the RMP table. It does, kinda, but in the pseudocode of those new insns in APM v3. From PVALIDATE pseudo: RMP_ENTRY_PA = RMP_BASE + 0x4000 + (SYSTEM_PA / 0x1000) * 16 and that last / 0x1000 * 16 is actually >> 12 - 4 i.e., the >> 8 shift. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette