Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1772635pxb; Thu, 7 Oct 2021 15:01:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNJNW52NZNQShJRu4P4rjAeJqESW59sLx7tzZSTXiRjXbf8nLTfOc/6/894CtR2GDsJT0+ X-Received: by 2002:a17:906:cd11:: with SMTP id oz17mr1274894ejb.67.1633644099762; Thu, 07 Oct 2021 15:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633644099; cv=none; d=google.com; s=arc-20160816; b=u+C97T/HZrOeSJihlXf3KkdDcEjaLKi+338Qw/4YEFMK5+PxhaI9eYNQv09fAs0l7X H/9yDDLHuEymn48J0MYtKQA6L2mxd3aCryTAKfzkzXNJRwhFV+U/k7/27TXGiXjdnCZX Id0rn/nVmAfdeODEZNAhsKEswROjkB4i/EpQypf1+Ohw1ElXf5HBsLTZpcvkWRKkvtA2 cuct/b0f3hzWTLqOmViiWOsj0ZXKc+z8gogEY31dUN5F1t+4YKp2NjAAoeIJ4Hk3o89F mSVNoChiY1R5OsUeddB03ZE+xyGq8YNrOoG5IXt4pKbVhP37/9e3gX5xFETzonXk+Bfp zH3w== 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=9ZsQxbDp8Ou6JmYRjo/eILd/d2Mdmi4Yw7to5qzMcMw=; b=vG+2IrVYF06Qq/IIzeXUue+H0xosTmriwsQp+JmHuedoY+khEXWjzxeDQwOs9lU+IL H72bVxoA75nc+6osc/Kf7CGMpvc5pScgEulWxps+nWQrDRNumElk1Vgjvx1eGR6InlNt DvoxFdObsQXzb1SAoBnjgaothuDBLYQXSec2glrQsD+my5vEJ1xIqB+hk8hZ6DG46qPR uw9JJnBZIs11eNQFs+om+BYs6SKWX+BJK+Tg6Sa7leN8vohhruEenDyQXwxLTS0T6uqw iYrLNv4j+FLk3FYbE9JMip5iWbnJZrB3630XlqPG5lt3Q7e/RFRwpdZDMdbOVr4XZVWq HO5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=WP4Kxx71; 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 t17si1050320edd.346.2021.10.07.15.01.16; Thu, 07 Oct 2021 15:01:39 -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=WP4Kxx71; 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 S243090AbhJGRIg (ORCPT + 99 others); Thu, 7 Oct 2021 13:08:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243081AbhJGRIa (ORCPT ); Thu, 7 Oct 2021 13:08:30 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD9EC061767 for ; Thu, 7 Oct 2021 10:06:35 -0700 (PDT) Received: from zn.tnic (p200300ec2f1265004099ae2673030416.dip0.t-ipconnect.de [IPv6:2003:ec:2f12:6500:4099:ae26:7303:416]) (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 B1CF71EC04B9; Thu, 7 Oct 2021 19:06:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1633626393; 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=9ZsQxbDp8Ou6JmYRjo/eILd/d2Mdmi4Yw7to5qzMcMw=; b=WP4Kxx71PuFKgHY6DUyRHpSVtdCTsOI1eN89B4uwM4BqtkKr4+/8IMvY5fWPIdQR8cr38P aA+4BQWSAZXhcYi1OOQxpcRq55TseJ5QDEVeXnZSRzSpEpXH0VAsCCmdKos4NoImCKe3An fEWemb8/WkWZNmTJdFkiELG2ugXHyKw= Date: Thu, 7 Oct 2021 19:06:27 +0200 From: Borislav Petkov To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , x86@kernel.org, Paolo Bonzini , David Hildenbrand , Andrea Arcangeli , Josh Poimboeuf , Juergen Gross , Deep Shah , VMware Inc , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 06/11] x86/traps: Add #VE support for TDX guest Message-ID: References: <20211005025205.1784480-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20211005025205.1784480-7-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211005025205.1784480-7-sathyanarayanan.kuppuswamy@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 04, 2021 at 07:52:00PM -0700, Kuppuswamy Sathyanarayanan wrote: > diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c > index d5fc2904facf..f7885c777a09 100644 > --- a/arch/x86/kernel/tdx.c > +++ b/arch/x86/kernel/tdx.c > @@ -6,6 +6,9 @@ > > #include > > +/* TDX Module call Leaf IDs */ > +#define TDGETVEINFO 3 > + > /* > * Allocate it in the data region to avoid zeroing it during > * BSS initialization. It is mainly used in cc_platform_has() > @@ -50,6 +53,36 @@ static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, > return out->r10; > } > > +unsigned long tdx_get_ve_info(struct ve_info *ve) > +{ > + struct tdx_module_output out = {0}; > + u64 ret; > + > + /* > + * NMIs and machine checks are suppressed. Before this point any > + * #VE is fatal. After this point (TDGETVEINFO call), NMIs and > + * additional #VEs are permitted (but it is expected not to > + * happen unless kernel panics). > + */ > + ret = __tdx_module_call(TDGETVEINFO, 0, 0, 0, 0, &out); Same question as before - why do you need to clear this @out thing above when __tdx_module_call() will overwrite it? What you should do instead is check that @ve pointer which you get passed in - it might be NULL. > + ve->exit_reason = out.rcx; > + ve->exit_qual = out.rdx; > + ve->gla = out.r8; > + ve->gpa = out.r9; > + ve->instr_len = out.r10 & UINT_MAX; > + ve->instr_info = out.r10 >> 32; > + > + return ret; > -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette