Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp64900rwe; Fri, 26 Aug 2022 00:16:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR4K7+KdPOuPDg7L33r23IgPfCxU8xnptF7WabZosAUCNAYhXu+S5QihXmpVjVLvHJVFisbg X-Received: by 2002:a63:8bc1:0:b0:42a:1604:3342 with SMTP id j184-20020a638bc1000000b0042a16043342mr2230336pge.368.1661498209370; Fri, 26 Aug 2022 00:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661498209; cv=none; d=google.com; s=arc-20160816; b=X1j5gvDvL9HhumOlu+BI+AL/MsQORavjdvPvpuzAvNuaNC21+tzG6cjyorM/4igour rrGiD0lvcipd5NVF8/jOBMV4ErY8OKH8HBoSnvRHXobr/uwz9ywi9Aw5A0fZqfmKCNiS hzBfY5+V6ZqWWiQ8C2cG4FjbaZ5g7dNTp4mna5Jy2pk478p1aej7uu0gX0g2GmtLaiZB 3S2mJbpFEeS4LmUaGLvtGb+QpM2+/64NiB3Z560Oxasil48mAspia6Mc5QD9fNSqWxbw o45K+Et5QzwFZTkiQyYcEi9QZ+hUQUjl+t+rcXGNJVxvnf+8rPnesZLrpdSHrO1Ap7+s 6HFQ== 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=uj3gozxe1gCyb2bIziJCE5C5mp6iXyEUe836YmXwevE=; b=B/l/LiQ3+PI1nP+9SjVgjtZPO9PqCYYbF7BQdj6RV9ftsGspFB2oR1yqiGNFCt8JyN PKPABaHR10FT7lQpCsd9f0xcd5d6lfqonVALuX6Gz77YF2SPbfZyYrHsb9bNxZK5Jxj9 MecbTNoiPAEZZkUWTTHF3s10apW9JLP27qtN2opF4WW9TPJWyaMHQTXsjoInryQqfEqU OgKEAwK4+BpEO6VhBorBA9ODH2AjopsbXgkJRM6WsSzbmdeZQ0Wk8i20oym+FSqbr/2l KLVSi9YJlp6dLomGmyxM1RQ63d4YFwCGrpHeAopzl43yZdd8IABCfm+jjoOLQ/gKhAPJ bKcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q4tkonXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k20-20020a170902761400b0016da4f41949si872657pll.550.2022.08.26.00.16.37; Fri, 26 Aug 2022 00:16:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q4tkonXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245066AbiHZGoY (ORCPT + 99 others); Fri, 26 Aug 2022 02:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238943AbiHZGoW (ORCPT ); Fri, 26 Aug 2022 02:44:22 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DDF4D1260; Thu, 25 Aug 2022 23:44:21 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id ds12-20020a17090b08cc00b001fae6343d9fso7213257pjb.0; Thu, 25 Aug 2022 23:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=uj3gozxe1gCyb2bIziJCE5C5mp6iXyEUe836YmXwevE=; b=Q4tkonXYl+lbcTKYBVtnzj/5vghRdqtwkQnFr85jVRoA67R4lZi3AcMGvEKsYPK4zn WAa7udtoVIK2N+mpSdHkwuPlzI7vy7319QYczCAbcP8T/fL90gsxatMNFNJBTQiH/luq 5fGRzPm9i6037skm8XlKRbOqhvs0V+F9O8LBl1focyUJjBUGo/aw3b7zqh4uIciIkr9P fzHJ3+JR5juPHo2Og1TJlIxQX8qQGJjMjYx3twsmotPnJHIjsiqYLhFZVEc34LwEEEmJ MibYrAC2MNveE2NxUYCR8aOpc/JurU1NQ8p6Oq/93qZdWYjkySW68Kwiy8KXRSoLwEbw v5gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=uj3gozxe1gCyb2bIziJCE5C5mp6iXyEUe836YmXwevE=; b=vf78Ko4kCJ+Yib2KsFuuSANhe/QXZkaH43teNTfvOSZYzN4BSmMc9NFyKSHUEpndgp XyP34CSxP+VDXdniHLVTRskFf2dWs4aRdLxMQsRJB78XjcbNmu6AsEZ/9QL8xWDtKjTS yJs5EMgOUU5Dvcgl21MVpek4jhv1HUc4PjyD2N6nXL0DKU9g5tLzZh2nbqJeqEV7ygw9 pCLl8ZIIZIgmVJ/kwFyZWhroNbOHHgE63QAmWWZO+T4FS8nofE3RUxnWk7f5KUaC51nA hZGVfGT5fRG3cNmsS+NjWTLqbUIorMAXfEfpRUvub6aB+06pxLQW46rnUGHo5eY59Wej n+SQ== X-Gm-Message-State: ACgBeo1UflTyz25CpYfrVf6sazvUFYBMTG48J1hfFlmoDXBJ37+/zmCE PJS45GOBdbRqX7lXUU6PGi0= X-Received: by 2002:a17:902:f542:b0:173:4136:83cb with SMTP id h2-20020a170902f54200b00173413683cbmr2414665plf.4.1661496260795; Thu, 25 Aug 2022 23:44:20 -0700 (PDT) Received: from localhost ([192.55.55.51]) by smtp.gmail.com with ESMTPSA id j17-20020a170903029100b00172ba718ed4sm717586plr.138.2022.08.25.23.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 23:44:18 -0700 (PDT) Date: Thu, 25 Aug 2022 23:44:18 -0700 From: Isaku Yamahata To: Erdem Aktas Cc: "Yamahata, Isaku" , "open list:KERNEL VIRTUAL MACHINE (KVM)" , open list , Isaku Yamahata , Paolo Bonzini , Sean Christopherson , Sagi Shahar Subject: Re: [PATCH v8 020/103] KVM: TDX: create/destroy VM structure Message-ID: <20220826064418.GF2538772@ls.amr.corp.intel.com> References: <810ce6dbd0330f06a80e05afa0a068b5f5b332f3.1659854790.git.isaku.yamahata@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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, Aug 23, 2022 at 05:53:00PM -0700, Erdem Aktas wrote: > On Sun, Aug 7, 2022 at 3:03 PM wrote: > > +static void tdx_clear_page(unsigned long page) > > +{ > > + const void *zero_page = (const void *) __va(page_to_phys(ZERO_PAGE(0))); > > + unsigned long i; > > + > > + /* > > + * Zeroing the page is only necessary for systems with MKTME-i: > > + * when re-assign one page from old keyid to a new keyid, MOVDIR64B is > > + * required to clear/write the page with new keyid to prevent integrity > > + * error when read on the page with new keyid. > > + */ > > Are we saying that we do not need to use MOVDIR64B to clear pages with Li? Yes. TDX module spec, Table 15.3: Checks on Memory Reads in Li mode says that read with shared HKID doesn't result in #MC. Read of poisoned cache line is another story, though. > > + if (!static_cpu_has(X86_FEATURE_MOVDIR64B)) > > + return; > > + > > + for (i = 0; i < 4096; i += 64) > > + /* MOVDIR64B [rdx], es:rdi */ > > + asm (".byte 0x66, 0x0f, 0x38, 0xf8, 0x3a" > > + : : "d" (zero_page), "D" (page + i) : "memory"); > > +} > > According to the Software Developer Manual, mfence is required for a > strong ordering on stores. Should we not use mfence here? Right. I'll add __mb(). thanks for catching it. -- Isaku Yamahata