Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3523683pxb; Sun, 7 Feb 2021 12:31:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJw70erruVUyN1Nqvitx0sla0BrJYCOsBBHbAZKmeHlYbWkpQmZJAr+Rphve19aPbj064oKK X-Received: by 2002:aa7:c64a:: with SMTP id z10mr13953552edr.61.1612729876689; Sun, 07 Feb 2021 12:31:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612729876; cv=none; d=google.com; s=arc-20160816; b=0KnvawVJoOQSjbynINCb57JE9i3yoontONCq/ltbNsXrvY9jHQmmQiXyxbkbWiq5pS 0mTWvo34q9jdfP2AZOOBR8WGSLC193urQHP7eFj3xw+Je8pte/7L8VmUIqHiMRJgW2sF /bzWl/lRCD6xbhYiy4+DdrFFEINeNRJemuvz5URtvHH5rXkMOP3FDzNXGstEmRz1avpU aLORx9AE7T9UbJUE5lX2ICIBKrX24VFzjBOD9fhqoMsso4+VklaUZwfjk0RVzAnkejJG 5ujENkm3zfVZVk9cluBITDgmX6590U+hpF8eOa5FRaQ8GanzNj6fK3xqE5Nag+kcAv7b s8Aw== 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=9sjBuurXuCRLTK7WBgtpDGv+6PLRJ/KauaGTkl6DnYA=; b=wwBpqh3Cad61H2s0uASwSWrqJEIJOkJrFhTSZImN1kbN/YLEAXWnjWq4yUwkgM6jUP KG1ncu9zD+J5HrxY4kTswBKBVeXrmOnkIr7b0CMRM5w3rVDqVf3yqEdarA82C4z5EKjB 9QWW6gnWIYhbxYDl2o7qsh+/Y35pcXQH9nx1M+4LH0M/9TOYXtmF+PojEdwChLAyEkVu PDtIBzJqBrxENKBC1EkItXLDF0adH82HScLA954FvjKcF0Aq7ISGBerGJ8NRUwqWNQUP K0OwBpkjyZFnfFM2WkYUl2JUgCQL3dEt82hK2LuU4QYotIW7NLbgZKraO3p3ocYjc6S9 cELA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=epWcFHVc; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox26si1671643ejb.144.2021.02.07.12.30.53; Sun, 07 Feb 2021 12:31:16 -0800 (PST) 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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=epWcFHVc; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbhBGU35 (ORCPT + 99 others); Sun, 7 Feb 2021 15:29:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbhBGU34 (ORCPT ); Sun, 7 Feb 2021 15:29:56 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 662FDC06174A for ; Sun, 7 Feb 2021 12:29:16 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id q12so19038033lfo.12 for ; Sun, 07 Feb 2021 12:29:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9sjBuurXuCRLTK7WBgtpDGv+6PLRJ/KauaGTkl6DnYA=; b=epWcFHVc2LXA+n9fYEyvBJuVljCuMGaWTK02BvCBbwqQKVGO/LQde7vvIlJswMCcR8 aJvPxjbcit3r8KPHxtKmIzzUw++F3c9PGnR13C/c4Ih5sUxsHQBUT/Pfo645HlH5opD+ pz8gTWWrt1HO5XMgzcIl59xiq9i8N1f95TEKb/O9pTMIGY1T/M9dXBNXWM1eEGJrpGpF UcD388HuT9A/JJPqTWhIDDTuP1Ipuk1blqyobFRlcvt+EvuXcqPhbBeM/Ya2LegRd7aS 6rjdeAsNbsPy31tpJCtIXzlhLXCMbv+YUov44rzzj4EENJVtVv8b74eH+C3306AOMus+ KOqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9sjBuurXuCRLTK7WBgtpDGv+6PLRJ/KauaGTkl6DnYA=; b=ELhW1EO0blzxb/i+GVh9TBYVgbEQoU7sh3FZ5VJQdp5fsw+9j9aVeFD9/RKTUH8LKR kQefET1uJfaR8xzDFErH7AxKWYBhxHqgqrCarxemVbie14QHOV0G56F3nN85QLQoTobE OCoAKuuN/fLnVV+ATsLZXJur1v91snXPDyw2CC+tdSP9KdkQUpo+mpTL6ZkeAVBDx2ES 6Md18ptjLtO4kB9XghEd+jKSeDFUQRtdgoAJp03LxvszMc1X7AKj4giPgyh8bsiym1LZ HX+76k0OLMthokw1JsB0wPOT/lu9f5BvSN0OXLRTGm10pxhyWW4/WiKr8Ott/zc9MBNL ELqA== X-Gm-Message-State: AOAM5325GnqomE6fGf9v1WEBCOjOSu1H2ltLQvxXuiapUCoTYly/W9bE 9c3RoF/akKFhkrbmgj6xO3TrbR3EYAv6lg== X-Received: by 2002:a19:6a07:: with SMTP id u7mr8096422lfu.97.1612729754807; Sun, 07 Feb 2021 12:29:14 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id j20sm1812898lfh.288.2021.02.07.12.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 12:29:14 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id E1FD3101B7A; Sun, 7 Feb 2021 23:29:13 +0300 (+03) Date: Sun, 7 Feb 2021 23:29:13 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Andy Lutomirski , Kuppuswamy Sathyanarayanan , Peter Zijlstra , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Dan Williams , Raj Ashok , Sean Christopherson , LKML Subject: Re: [RFC v1 09/26] x86/tdx: Handle CPUID via #VE Message-ID: <20210207202913.ov3kwlwnsn47v3tb@box> References: <20210207141304.kdjg732lzh5uzz7i@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 07, 2021 at 08:01:50AM -0800, Dave Hansen wrote: > On 2/7/21 6:13 AM, Kirill A. Shutemov wrote: > >>> + /* Allow to pass R10, R11, R12, R13, R14 and R15 down to the VMM */ > >>> + rcx = BIT(10) | BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(15); > >>> + > >>> + asm volatile(TDCALL > >>> + : "=a"(ret), "=r"(r10), "=r"(r11), "=r"(r12), "=r"(r13), > >>> + "=r"(r14), "=r"(r15) > >>> + : "a"(TDVMCALL), "r"(rcx), "r"(r10), "r"(r11), "r"(r12), > >>> + "r"(r13) > >>> + : ); > >> Some "+" constraints would make this simpler. But I think you should > >> factor the TDCALL helper out into its own function. > > Factor out TDCALL into a helper is tricky: different TDCALLs have > > different list of registers passed to VMM. > > Couldn't you just have one big helper that takes *all* the registers > that get used in any TDVMCALL and sets all the rcx bits? The users > could just pass 0's for the things they don't use. > > Then you've got the ugly inline asm in one place. It also makes it > harder to screw up the 'rcx' mask and end up passing registers you > didn't want into a malicious VMM. For now we only pass down R10-R15, but the interface allows to pass down much wider set of registers, including XMM. How far do we want to get it? -- Kirill A. Shutemov