Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp184821pxh; Thu, 7 Apr 2022 18:13:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnPtwV/Np653XXTWBBsMyuIjFaTg0kJrCwQQ9hl6fbY4KlZNHIJhhFGtXUUS2+WhZnbURo X-Received: by 2002:a17:902:f64d:b0:151:3895:46bf with SMTP id m13-20020a170902f64d00b00151389546bfmr16845969plg.31.1649380416905; Thu, 07 Apr 2022 18:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649380416; cv=none; d=google.com; s=arc-20160816; b=fBjLiGpeUCZKPDP2bZrso+D+LqI0PKyJpIToER4MWg8KIrXf5JPqz3sIuZ7k9EW2Mg BKqha5BgQZXbkAMd/X+sueMTlUjqr2Pjib7oteioJzTm45KoQacpBnzW8M0xHqwJi6So sXYhTk07ocSUY/5N+IBwzgxzAadl+SqhjO+psjXt2EAt42sC1TEz8iG1tNVigM2MSzyD IgAEdWY9qaEmXAGvRoO/LQjOmAbIk9LSxhIBdjV42jlo4hPiEL4wih0VOX1KXmqiHVJ8 ykwDpY9wigGECuU2fYRldZu8qxZ4qgl06iN9sforPOg6e17WwY43+3tjYz7EDUbW+Yfc 0U9Q== 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=Bv8b36R/JYSKrjInAZ8YiQDmdZkHb/0Vx7ZZQr7wN9w=; b=iZTdgDSymY33IOVMEsXqJR6e1K0OjYpO6zHED/AU5cfa8vKsfjRo0XnqLCBfgTsP53 sZjG4QLafu68payH7jCAROWV4ai/r2cy4s4pdBlct2aDoSjopr/FZRBTz44pYnQI52dv wk2CkjmsTF3+3vdNyH3qLBl7HJNA3BZAl+IkD0vJtfn3P9vX+ef6bLUw49iHEewGBQJq 40rfjtzjHi1cnPezGP8p0A0MPYgAZQ/1TPSfPsWL/G/QkHdx+Ql2Y8+rG6MY0i/NFuIu XdL5GF3wJOfmHl6vgNwVsAzVGaMMj+3fsZCuJDCQXe8foR+V29w0Mro+kbbi1OQEg9rj hmpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FE1F7tzl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b19-20020a17090a991300b001cabc1752c8si3139603pjp.82.2022.04.07.18.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 18:13:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FE1F7tzl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D00A16D4C1; Thu, 7 Apr 2022 17:44:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233028AbiDHAql (ORCPT + 99 others); Thu, 7 Apr 2022 20:46:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbiDHAqh (ORCPT ); Thu, 7 Apr 2022 20:46:37 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B0960CDE; Thu, 7 Apr 2022 17:44:33 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id t4so6421091pgc.1; Thu, 07 Apr 2022 17:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Bv8b36R/JYSKrjInAZ8YiQDmdZkHb/0Vx7ZZQr7wN9w=; b=FE1F7tzli7WL4l6VnR9bc1kj3unM1hEzEe5CcNlNniQoTJ3l7dkFGNALbE6fDfdSmR qIVvhWuUX0Gw9cZ/w39gB1PlsdSLotrdHuqacckLzHVspgRA5kanxLLTLuM9kbliDdGk 6+0178qjHV0v1np3ML8om1zdnMOZeMKU7gPCT9pgYgV5pEQm0tRBmRzkCjBRGjHxx3q/ 1ZUv8aXuwGJsnNx9YyXheL8cBwuzY+HPYL8rNEKcgncv0pMo5Il4TdeuLm2vVo1ie2Wd QP9lrEUC5ARQ3lwecQ/Tf4sSkI9wc7GFQEIPusF9Qcq1CUSUiyF6mXyQRH9eTp99/V/V h0ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bv8b36R/JYSKrjInAZ8YiQDmdZkHb/0Vx7ZZQr7wN9w=; b=yaGulZh7P5cFIKTRsmo74dC/LSRrGkQya8EmzTyJPXBeLVaQTGySRFlb5FAOX8Lf/e ZC7yokKm7QORAal+BYvxSPcMwKIT3xkbDwKuJ1eXtg2KxsqbeRlGB7rYqLpyHjmj8bwN R+V6RdxreNQy/+hhtFkWDBevvV5aGizzvgFz75J9+2G+Z/yQKW8se7uCax+oiVUO7047 s6xzEsjRUSrS35ANmLx+FrRHmQUwBstIaRFi4zydVbSSyWX23+wp68yi/xF5XUCH6nAF s1wUZmrnnF/dp0diLTWwrbj9hSnShY1lUDhag84VEcGoeab8d216ktHID6ZGhJkLROS2 4CpA== X-Gm-Message-State: AOAM531V1i8JvmHOjH44rKuJHLs5gBINoV+3+ckiVsvaJzM1fh9dYRFr geqmuY9o9qeCNKt7nOUbZaY= X-Received: by 2002:a05:6a00:2484:b0:4fa:997e:3290 with SMTP id c4-20020a056a00248400b004fa997e3290mr16810645pfv.37.1649378672571; Thu, 07 Apr 2022 17:44:32 -0700 (PDT) Received: from localhost ([192.55.54.52]) by smtp.gmail.com with ESMTPSA id oa16-20020a17090b1bd000b001c72b632222sm10335976pjb.32.2022.04.07.17.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 17:44:32 -0700 (PDT) Date: Thu, 7 Apr 2022 17:44:29 -0700 From: Isaku Yamahata To: Paolo Bonzini Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Subject: Re: [RFC PATCH v5 020/104] KVM: TDX: allocate per-package mutex Message-ID: <20220408004429.GA2864606@ls.amr.corp.intel.com> References: <25257849-8e1a-17ff-5008-bb2d1efecf80@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <25257849-8e1a-17ff-5008-bb2d1efecf80@redhat.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 05, 2022 at 02:39:51PM +0200, Paolo Bonzini wrote: > On 3/4/22 20:48, isaku.yamahata@intel.com wrote: > > From: Isaku Yamahata > > > > Several TDX SEAMCALLs are per-package scope (concretely per memory > > controller) and they need to be serialized per-package. Allocate mutex for > > it. > > > > Signed-off-by: Isaku Yamahata > > --- > > arch/x86/kvm/vmx/main.c | 8 +++++++- > > arch/x86/kvm/vmx/tdx.c | 18 ++++++++++++++++++ > > arch/x86/kvm/vmx/x86_ops.h | 2 ++ > > 3 files changed, 27 insertions(+), 1 deletion(-) > > Please define here the lock/unlock functions as well: > > static inline int tdx_mng_key_lock(void) > { > int cpu = get_cpu(); > cur_pkg = topology_physical_package_id(cpu); > > mutex_lock(&tdx_mng_key_config_lock[cur_pkg]); > return cur_pkg; > } > > static inline void tdx_mng_key_unlock(int cur_pkg) > { > mutex_unlock(&tdx_mng_key_config_lock[cur_pkg]); > put_cpu(); > } Sure, will do in the next respoin. -- Isaku Yamahata