Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp300319rwl; Wed, 4 Jan 2023 19:45:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXvThwn77YM6X60VEjwBnImk2WaSOHs3/Sd+mos8YwCImkUnLGihnFMK99Li1scq02b/tu+U X-Received: by 2002:a17:907:7f04:b0:7c0:a4e9:615b with SMTP id qf4-20020a1709077f0400b007c0a4e9615bmr54480426ejc.61.1672890330601; Wed, 04 Jan 2023 19:45:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672890330; cv=none; d=google.com; s=arc-20160816; b=dP0+3zHINXMEgrfsno1/2gCvzqj/BOYvhhEzJ2fG+5POqw/s6UI78IzpqYn4CFgVL9 8aFA1znmAiLFMa0PUFAlCKIX4c3dAh/fq2BVwxagtKgGV7fJ67knZBn4zLb4eLvodHEf afE/aQS/dS62G9BLTA5OCs958oy+BHREdO/tUczqwNZ2Q6slW7z2eiDRTarQ6OnW6tot lPqxplpH8OuEl/62jOZu18LapwHrp4hSDmqjpCWfeudhzTjV1pVy7vheuPOmbR1B6Mqv qdh04IZrDoEnkzsBf9gFcghGlB2M72ui4zsSkFjIVW2ImxFPeMLRzh9tl6OriagS+Kqn owZQ== 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:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=o6JH9jd5EO4UcXmANGw+9sT3I/5Mb3/7J9kyVuv6/RU=; b=zZ3qyo4xtPYDaLEcgrif516yEAtBBi0c7JRLdWOWYG3nCt0tQRaVzyj/qCIl4iJXxe 61l80bTzsuEGJKrK+VacvpVvFClqe6ra0W4FGHPD6XUbX7GGMrc6v4OMULKN9SkW/nK1 dYb+uqpNGbpVaRp/OZk4in/Wdnu5jTpccpgS7+hoW76LWpmDQ41HlAcbKl7ODna95XzA 2EeC00m+b/e/ZI4dzcrDX7E8ESUy7psJ5S+mCRmi4jWmQ3cA8xStHvISz2/hc0TrYYQC w2GpNQJMW6EMPOATx2cAF9lb9KRAVjFjk6TrQPqhw1ygrux0J/9LINKB/4C/Hv50wzXI PMGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ElbdV5eT; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 ga33-20020a1709070c2100b0084c4942ea8esi27635615ejc.268.2023.01.04.19.45.00; Wed, 04 Jan 2023 19:45:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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=ElbdV5eT; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 S230172AbjAEDjj (ORCPT + 99 others); Wed, 4 Jan 2023 22:39:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbjAEDjP (ORCPT ); Wed, 4 Jan 2023 22:39:15 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B55E748CE6; Wed, 4 Jan 2023 19:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672889954; x=1704425954; h=date:from:to:cc:subject:message-id:reply-to:references: mime-version:in-reply-to; bh=7+whF6O83FkAi7trCF9TEjov28V0K0S8cRinP/bHSI4=; b=ElbdV5eTGT0Yeh0HM7g0ELxfawM/y47UILcCEBkPM68kEcmsvpMG+yo2 cXyNaWIwr5t8fjT02RdsoajI+ciGPSFbNWp73UECvKAgpC7jDrabEqrBH EgVTKZeEapj7m8WNX4e00SdxMrrq2WYVewX2G0SVcSbWm/FrjexK91IXG 41WXjiJSG/GHmgk94LfsV1ZUi0KFQYzdg9w/KZtSHupwiikwFlSHYKxdS hNCtxMFuWG2qNqyDsnLN9xtVyKWNSROjcQ0k9l/cq+XlD/Gb+2ugG23W2 2O+SAOO4XgMQdA4ML+KfswJKuUmxX9tvfRWUSmQCxaOAeX5WaRqWLy4E+ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10580"; a="349328871" X-IronPort-AV: E=Sophos;i="5.96,301,1665471600"; d="scan'208";a="349328871" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2023 19:39:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10580"; a="829394357" X-IronPort-AV: E=Sophos;i="5.96,301,1665471600"; d="scan'208";a="829394357" Received: from chaop.bj.intel.com (HELO localhost) ([10.240.193.75]) by orsmga005.jf.intel.com with ESMTP; 04 Jan 2023 19:39:04 -0800 Date: Thu, 5 Jan 2023 11:34:51 +0800 From: Chao Peng To: Jarkko Sakkinen Cc: Michael Roth , kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, jroedel@suse.de, thomas.lendacky@amd.com, hpa@zytor.com, ardb@kernel.org, pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, luto@kernel.org, dave.hansen@linux.intel.com, slp@redhat.com, pgonda@google.com, peterz@infradead.org, srinivas.pandruvada@linux.intel.com, rientjes@google.com, dovmurik@linux.ibm.com, tobin@ibm.com, bp@alien8.de, vbabka@suse.cz, kirill@shutemov.name, ak@linux.intel.com, tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com, alpergun@google.com, dgilbert@redhat.com, ashish.kalra@amd.com, harald@profian.com, Nikunj A Dadhania Subject: Re: [PATCH RFC v7 01/64] KVM: Fix memslot boundary condition for large page Message-ID: <20230105033451.GA2251521@chaop.bj.intel.com> Reply-To: Chao Peng References: <20221214194056.161492-1-michael.roth@amd.com> <20221214194056.161492-2-michael.roth@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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-crypto@vger.kernel.org On Wed, Jan 04, 2023 at 12:01:05PM +0000, Jarkko Sakkinen wrote: > On Wed, Dec 14, 2022 at 01:39:53PM -0600, Michael Roth wrote: > > From: Nikunj A Dadhania > > > > Aligned end boundary causes a kvm crash, handle the case. > > > > Link: https://lore.kernel.org/kvm/20221202061347.1070246-8-chao.p.peng@linux.intel.com/ > > Chao, are you aware of this issue already? Thanks Jarkko adding me. I'm not aware of there is a fix. > > > Signed-off-by: Nikunj A Dadhania > > Signed-off-by: Michael Roth > > --- > > arch/x86/kvm/mmu/mmu.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > > index b1953ebc012e..b3ffc61c668c 100644 > > --- a/arch/x86/kvm/mmu/mmu.c > > +++ b/arch/x86/kvm/mmu/mmu.c > > @@ -7159,6 +7159,9 @@ static void kvm_update_lpage_private_shared_mixed(struct kvm *kvm, > > for (gfn = first + pages; gfn < last; gfn += pages) > > linfo_set_mixed(gfn, slot, level, false); > > > > + if (gfn == last) > > + goto out; > > + Nikunj or Michael, could you help me understand in which case it causes a KVM crash? To me, even the end is aligned to huge page boundary, but: last = (end - 1) & mask; so 'last' is the base address for the last effective huage page. Even when gfn == last, it should still a valid page and needs to be updated for mem_attrs, correct? Thanks, Chao > > gfn = last; > > gfn_end = min(last + pages, slot->base_gfn + slot->npages); > > mixed = mem_attrs_mixed(kvm, slot, level, attrs, gfn, gfn_end); > > -- > > 2.25.1 > > > > > BR, Jarkko