Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1680444pxb; Thu, 7 Oct 2021 12:44:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEiJH9/MSFiphOnQ19fJFb8/XnG8bIXnjGA/iNrOgBSBW3b2q/S8eyZIS5rHMStn0D5wC1 X-Received: by 2002:a17:90b:1910:: with SMTP id mp16mr6622402pjb.107.1633635870717; Thu, 07 Oct 2021 12:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633635870; cv=none; d=google.com; s=arc-20160816; b=XTITLDT+zZ2/oReMivwU09h4//flPZfdzah42LB5NTgxRxg1naTR1b/OdXaoE48IEs eHF/2Fw2kRgp0qCsT7q8QmJ99bCsYlh8BbLCTAwa2T7Pb8jlHb7GEVJU9TnGDY90wJ+Z nnr5ZYr/FmxAXFYIQ2CMUPcJpgXiWHM46K5TSvKoxmWdtkrmw9PUD7+tg/naFGEkie6o 8c9Q0cCyvSXorfUrDWj96ffIulE1UM72ou8wns87eu+/H11E8UtMtDmMv4eNmbvivJSw /Dq79jF+yBv8RVkxLZUcS6xq6BMtczIeEh7f4UG+i6rmcvWlt+B8zaHE7bkzftem1Xb2 i0ZQ== 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=YGcYP1zfWhrMRhm5NbdQtlJR8s9PibrnwvK1f5I30BQ=; b=Lo8lRI8I3qJumTQf4WxdUxto5rsvMQqEgJm9e36IdnIbZPLkC8QMCy/dOt5+49TI6P K9ER7QdtwZwfO7QOQa7rSK+yKCCyKvxX3dCfMMN5vFK8eOBNHLUOgpbuRwKgYamTitFV seYHsoWAcMYqGjUGyQtni3RBSPm6kv/W/dUUaIXM7TuB4Bo7Zi+gPClyIqQim5yA5TAq aQzUwjQ4T1tGYsgvG5ToqOTt80zX7dVTJT7OyDPVxkQqhzFWbVegOyoYfN0iij3dl2Vr WtNh13HAf+8FUfrhKTh4YA6dJbfUYFBz0gj9Sa6PkS4yDJxzMl4nPj3rT522KeNknGfd lDsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=nnnET05z; 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 q12si330949plk.313.2021.10.07.12.44.14; Thu, 07 Oct 2021 12:44:30 -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=nnnET05z; 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 S242845AbhJGRek (ORCPT + 99 others); Thu, 7 Oct 2021 13:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242864AbhJGRei (ORCPT ); Thu, 7 Oct 2021 13:34:38 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82268C061570 for ; Thu, 7 Oct 2021 10:32:44 -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 086A01EC04B9; Thu, 7 Oct 2021 19:32:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1633627963; 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=YGcYP1zfWhrMRhm5NbdQtlJR8s9PibrnwvK1f5I30BQ=; b=nnnET05zB562mv1HWdbRoxV56lvPyBNXpZ6WCmZhXY5bgZw357a2040goJuGQgk4l5TE6H PSZgrUcU4sHJiKzT3yX8YugFht+U9eK3cdEGpobqZn6Ix02TQsaL7Ge8fVeXMIURnbs2xw d0N4W6fI5f+4w+wSTr46I8CpJyLdl6o= Date: Thu, 7 Oct 2021 19:32:39 +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> <9693938e-4171-90ec-1bbe-ee88e6452bd0@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <9693938e-4171-90ec-1bbe-ee88e6452bd0@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 07, 2021 at 10:22:16AM -0700, Kuppuswamy, Sathyanarayanan wrote: > Now checking again, I think we don't to initialize the @out pointer. I will > fix this in call cases. > > But for tdx_get_ve_info() case, we are updating the @ve pointer without > checking the tdcall return value and __tdx_module_call() will update the > @out only if tdcall is successful. Currently due to @out=0 initialization, > this logic does not cause any issue. But to properly fix it, I need to > check for tdcall return value before updating the @ve value. Yes, that looked weird too but I assumed since you enforce @out to be non-NULL, you know that you'll get ve-> populated. However, yes, you need to check the retval for that other case: /* Check for TDCALL success: 0 - Successful, otherwise failed */ test %rax, %rax jnz 1f > Current use case of tdx_get_ve_info() can never be NULL. But if you > want to add this check for possible future issues, I can do it. > > arch/x86/kernel/traps.c:1205: ret = tdx_get_ve_info(&ve); > arch/x86/kernel/tdx.c:945: if (tdx_get_ve_info(&ve)) Yes, you want to fail gracefully in the case where someone forgets to pass in a proper pointer to tdx_get_ve_info() in the future. As it is now, the guest would simply explode and that is not nice. Also, that function doesn't need to return an unsigned long if all it wants to return is a bool, from looking at its call sites. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette