Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp964487iog; Wed, 15 Jun 2022 16:56:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v/R20IQMs3lwKfrJpSendOd9I0TyMZOT2pRHu0IRjpjETB0tyrwK0I3zgH0fYZ5PfCjU3U X-Received: by 2002:a17:906:3899:b0:715:9fb4:bd28 with SMTP id q25-20020a170906389900b007159fb4bd28mr2084257ejd.97.1655337416830; Wed, 15 Jun 2022 16:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655337416; cv=none; d=google.com; s=arc-20160816; b=i7INxSvmwALn3jxa1s7VmaVTC/6kGMC43thNHdPhgtXRw+47FDPVwoEUtvkwcgLPCn PO7/XUiCj0FpNOB6F1ohM6b9VchiBic8pDPzT5Et+BXJc5HcZUXQcSDT0J3myft0TPEj Wt6bTBaGB+qeGeM7wAbFtjlu7QP/IR6slMXqguBB3btDYlE7MqaeUdb2VRLxBMXkuuuu QSnPmnoqBDJYGD6h4dA8BeEMgtQa8uf7RCzOCq0EWtGonWtSZI+MM/M4k/kPTm8U+98p p982B/U+1z/SL12uuyof8Q2YvGNOKY2CMdM8LadpZ85ZDKAoe9Z44E2knOKKEW8/yKcN 5fAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1l4B5fhcQeo6CVBntYBpAistcnI9vVf8qGHg+ZElthM=; b=vGHn87PLfEw/GqyzxweRaFA3TkiEWLafoHSgYXc8yczPvjG3XuPqLqqLYNvVzHxBdM 2AJzhiZPd9CN4mE4Cx7tzHX5bcis+bwk1Mkyxo8FNb6Cm66RpDDbBlxXSxkqcfYYD2kd +PkbFnVfizybDYe0y3rwXL5TxLx+FpqJGxLsh4QvwyQWlL+w9HQ01oRKZkA+Gqzu+gVZ CpJmVZxZIt58YpT7G4zhSnuZAZJQLR0ThhfCIuXOuZcehKBqh8boS7096GXs3N176Ymg kQh1gc64RlHx5Axl1pV3UJWjftQhfq2qwMX28e29t5GjS0aDDZPl7gndczdgLZMgsRAX Ildw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BHRmxsMg; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a170906518700b006f3a874f673si218950ejk.4.2022.06.15.16.56.31; Wed, 15 Jun 2022 16:56:56 -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=@intel.com header.s=Intel header.b=BHRmxsMg; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350557AbiFOXev (ORCPT + 99 others); Wed, 15 Jun 2022 19:34:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350553AbiFOXev (ORCPT ); Wed, 15 Jun 2022 19:34:51 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13FF51A077 for ; Wed, 15 Jun 2022 16:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655336089; x=1686872089; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=FVibG3O2Jo4wE/8uawKSqXUP1QevxdRcM/UXljHqIJU=; b=BHRmxsMg380f1oJMBB9HtZ4qpNP3bQEB4V1fj83+PAFOWktIPAPsArKB 1CivRE9WAD1CRkGymR/6NL6J2BX6MyLHJZkndyys1Aoh+n3T7EyBvpN0l ysxyF7cgWfkGwaCuI7OcNxxCqIueX51BwKUggPq1GI156NFC8XoSlCQTA EGc8YiUUa5S9lb4rM/DrlPNihIJeXw2qbq9B5Cm3aEhAsargLPeFrKOep 5pEXxc/l05pG8WMf/4zH6pQn3/erYm8CXf+1riZNIMOXtFrSPseWnRLIl n7Vdh+7Q5wlmeODnS2bMawfp4gNsUtWv7ERVOlyXfeTKLQacdaYABQ8g6 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10379"; a="277920172" X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="277920172" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 16:34:48 -0700 X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="559425521" Received: from mjortiz-mobl.amr.corp.intel.com (HELO [10.212.185.241]) ([10.212.185.241]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 16:34:48 -0700 Message-ID: Date: Wed, 15 Jun 2022 16:34:48 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCHv4 3/3] x86/tdx: Handle load_unaligned_zeropad() page-cross to a shared page Content-Language: en-US To: "Kirill A. Shutemov" , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, luto@kernel.org, peterz@infradead.org Cc: ak@linux.intel.com, dan.j.williams@intel.com, david@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org, sathyanarayanan.kuppuswamy@linux.intel.com, seanjc@google.com, thomas.lendacky@amd.com, x86@kernel.org References: <20220614120135.14812-1-kirill.shutemov@linux.intel.com> <20220614120135.14812-4-kirill.shutemov@linux.intel.com> <20220615225200.lflv4tbqus6lnj5u@black.fi.intel.com> From: Dave Hansen In-Reply-To: <20220615225200.lflv4tbqus6lnj5u@black.fi.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,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 6/15/22 15:52, Kirill A. Shutemov wrote: >> + vaddr = (unsigned long)insn_get_addr_ref(&insn, regs); >> + if (vaddr / PAGE_SIZE != (vaddr + size) / PAGE_SIZE) > Oops. I just realized it has off-by-one. It supposed to be: > > if (vaddr / PAGE_SIZE != (vaddr + size - 1) / PAGE_SIZE) That was bugging me. Glad you caught this. Wouldn't this be more obviously correct? if (ALIGN_DOWN(vaddr, PAGE_SIZE) != ALIGN_DOWN(vaddr + size, PAGE_SIZE)) ... I don't think we have a PAGE_ALIGN_DOWN().