From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1B6FC07E95 for ; Tue, 20 Jul 2021 10:30:15 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 75C776113C for ; Tue, 20 Jul 2021 10:30:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75C776113C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id F34914B0F5; Tue, 20 Jul 2021 06:30:14 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1yxmFMAYhIeL; Tue, 20 Jul 2021 06:30:14 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id F39AA4B098; Tue, 20 Jul 2021 06:30:13 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2EB184B08E for ; Tue, 20 Jul 2021 06:30:13 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jzuGQmhNVl80 for ; Tue, 20 Jul 2021 06:30:12 -0400 (EDT) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 161364B088 for ; Tue, 20 Jul 2021 06:30:12 -0400 (EDT) Received: by mail-wm1-f44.google.com with SMTP id l6so12017137wmq.0 for ; Tue, 20 Jul 2021 03:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yyHhpf3IFAZa8+1SI9IG6peKhoOSRw9FB1qV/j0MUk8=; b=PhXJaFKOpcy2R87A3f53vk2DTtTJTWwcjsKW3ZIokani62gKo5jR0aptPSmRJ/1fTA 6DTZ6pKoaLfDrl4bXXLSOUBjVLCt7f5wxvv4LQMWoTuqMv0cxIUiPLbommSaffKuRjrP gOmxbCxfzZ7GDSNvdtbSL2rHvQELDImGwvWMlagzTJLTsFQ/sqVZYBhcLuUrRLjO5xop 0BAAZHK1brhUGSN7QZ6Rc5KkPqMNq2A9quWdZax1xJCcYYfyGp0q8AOgjjkeOo8R2jk8 LznC5t+fgx50pyAxYWv1XtdF/r48ir3eBkYYr7JNEU1eMnPFNXlYweVxAtymaGdW9yV1 SiQg== 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=yyHhpf3IFAZa8+1SI9IG6peKhoOSRw9FB1qV/j0MUk8=; b=PvIc8MH9jV1T3WT0i3ziZ2CGiaL/t7LmSMIzO3zMMlvo1ZCfcJc6TW2MhwFBZDAu5P qIGNP+RnbfokPsVKrO4qOHVa1X3DUiBH2kfTqHU90i8Cb9xFfQHuDsX3DabjCgsiEZzW l7gq/+G6D2LzCG2Hrzk6ogqfziDi/68OQEkAAHeIPPld0tTVrHTcNCV0qGktdT0n7n0C hc6J58KbI3j9sjBPrQKu7n0vPwXl/loJg8aYvSSgqASmfoJ0Vp187EY+58gxGrmIyL8Z lcjEnNq485JFyTwIoeGoUXTTMfypYBwzZz03bL8Fz8PL3pbXOEEVX2tmOtkOuELxoTdM Gb0A== X-Gm-Message-State: AOAM531D0A7k1CeoJgZ5gpzglT9Pc8El/Ui5LQi5rrcg7h3aEkAv0URa aca3RYEJb7bO/rIw4WaC5ocTXg== X-Google-Smtp-Source: ABdhPJzn7ppEiI6BziSUJrI9AZI83z3s8BqsMlMXuRgHmlK8PB4VVXduDhaZmxWobhXPrKosB7ng7A== X-Received: by 2002:a05:600c:2255:: with SMTP id a21mr30864834wmm.90.1626777010977; Tue, 20 Jul 2021 03:30:10 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:83e0:11ac:c870:2b97]) by smtp.gmail.com with ESMTPSA id w15sm2558095wmi.3.2021.07.20.03.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 03:30:10 -0700 (PDT) Date: Tue, 20 Jul 2021 11:30:07 +0100 From: Quentin Perret To: Fuad Tabba Subject: Re: [PATCH 06/14] KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits Message-ID: References: <20210719104735.3681732-1-qperret@google.com> <20210719104735.3681732-7-qperret@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: kernel-team@android.com, qwandor@google.com, maz@kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi Fuad, On Tuesday 20 Jul 2021 at 11:17:03 (+0100), Fuad Tabba wrote: > Hi Quentin, > > > On Mon, Jul 19, 2021 at 11:47 AM Quentin Perret wrote: > > > > The current hypervisor stage-1 mapping code doesn't allow changing an > > existing valid mapping. Relax this condition by allowing changes that > > only target ignored bits, as that will soon be needed to annotate shared > > pages. > > > > Signed-off-by: Quentin Perret > > --- > > arch/arm64/kvm/hyp/pgtable.c | 18 ++++++++++++++++-- > > 1 file changed, 16 insertions(+), 2 deletions(-) > > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index a0ac8c2bc174..34cf67997a82 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -362,6 +362,17 @@ static int hyp_set_prot_attr(enum kvm_pgtable_prot prot, kvm_pte_t *ptep) > > return 0; > > } > > > > +static bool hyp_pte_needs_update(kvm_pte_t old, kvm_pte_t new) > > +{ > > + if (old == new) > > + return false; > > + > > + if (!kvm_pte_valid(old)) > > + return true; > > + > > + return !WARN_ON((old ^ new) & ~KVM_PTE_LEAF_ATTR_IGNORED); > > Wouldn't this return false if both ignored and non-ignored bits were > different, or is that not possible (judging by the WARN_ON)? Correct, but that is intentional, see below ;) > If it is, then it would need an update, wouldn't it? Maybe, but if you look at what the existing code does, we do skip the update if the old mapping is valid and not equal to new. So I kept the behaviour as close as possible to this -- if you change any bits outside of SW bits you get a WARN and we skip the update, as we already do today. But if you touch only SW bits and nothing else, then I let the update go through. That said, I don't think warning and then proceeding to update would be terribly wrong, it's just that a change of behaviour felt a bit unnecessary for this particular patch. Thanks, Quentin _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34D21C07E95 for ; Tue, 20 Jul 2021 10:32:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08B036101E for ; Tue, 20 Jul 2021 10:32:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08B036101E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q/93gmYmawUhiVKicDxShMfsX3CHRBADnuvgawCXxH4=; b=nb/HBJ0Jsg1f35 x6xGW0pjAJFCR0K4dw+0qxr0d8I0GcoHtA60VCb7J4uWmm22CwTo27vIebI8BSibq6iWau/GdFWyJ Bn/VqDOdonZT1WCj72Zzalq1c4dAWvc85vOG3O6eacF2R2+PegtcnHEou6zYxNr0a7GmJLs9V2wet xmkTu0g+4IEf3BVb1fs9+3/Qs3pznRJkkSyOLW/24SPGSq1XfPMC/S8M80e0TFItMeBo2GL/yGB+l Hf+I7SzS7cdyeJjDmZs1tHyLxH3wj2XnN1903Lqzs2wMUpHEYCsKWEPDzBY5SKgq77IW8WhMm0yiF 9PKMoYiJWtm1iTLSUnNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5n19-00CWOf-Ou; Tue, 20 Jul 2021 10:30:27 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5n0u-00CWMB-Al for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 10:30:13 +0000 Received: by mail-wm1-x336.google.com with SMTP id m11-20020a05600c3b0bb0290228f19cb433so1214173wms.0 for ; Tue, 20 Jul 2021 03:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yyHhpf3IFAZa8+1SI9IG6peKhoOSRw9FB1qV/j0MUk8=; b=PhXJaFKOpcy2R87A3f53vk2DTtTJTWwcjsKW3ZIokani62gKo5jR0aptPSmRJ/1fTA 6DTZ6pKoaLfDrl4bXXLSOUBjVLCt7f5wxvv4LQMWoTuqMv0cxIUiPLbommSaffKuRjrP gOmxbCxfzZ7GDSNvdtbSL2rHvQELDImGwvWMlagzTJLTsFQ/sqVZYBhcLuUrRLjO5xop 0BAAZHK1brhUGSN7QZ6Rc5KkPqMNq2A9quWdZax1xJCcYYfyGp0q8AOgjjkeOo8R2jk8 LznC5t+fgx50pyAxYWv1XtdF/r48ir3eBkYYr7JNEU1eMnPFNXlYweVxAtymaGdW9yV1 SiQg== 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=yyHhpf3IFAZa8+1SI9IG6peKhoOSRw9FB1qV/j0MUk8=; b=J7r2VVRMXiR2n2GwqHq7XTXTkPnRXezh4kXP53Vy8ff92yyjrO7qj9FNwLQwMHnIaO m9ltqs17Hbm6bAl/jss48pc7crYZg6dMCZHXxhi1TA4K6Jc9idEk9sfCx4lcQYnAkTyG ZITY+DUUgVH2x1hS7T40OExGMjtaYMY5kZ1Px1cVq6q62GUe8bUC214AvoWwvRa5pmgo Wyq1s6puYJtvG7UNOezApv77LL4DuIfxhSY9+1Ma8NcG+x/2QjKoP68QXAQJUkW2DIZ8 RDSV5kViMHk1j0goJuk24vDxUSUpPytLZd9j93SCCr/sthTY0wqQTn6jma2EKB1OKtSu mKFQ== X-Gm-Message-State: AOAM531k6YzPhsSTrL66VmHlfKmIOQuW0YboYQ55FZGQaMy0Z1UNR77c UYSpp3A2+FHNd0K71h0mut07Fw== X-Google-Smtp-Source: ABdhPJzn7ppEiI6BziSUJrI9AZI83z3s8BqsMlMXuRgHmlK8PB4VVXduDhaZmxWobhXPrKosB7ng7A== X-Received: by 2002:a05:600c:2255:: with SMTP id a21mr30864834wmm.90.1626777010977; Tue, 20 Jul 2021 03:30:10 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:83e0:11ac:c870:2b97]) by smtp.gmail.com with ESMTPSA id w15sm2558095wmi.3.2021.07.20.03.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 03:30:10 -0700 (PDT) Date: Tue, 20 Jul 2021 11:30:07 +0100 From: Quentin Perret To: Fuad Tabba Cc: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, dbrazdil@google.com, kernel-team@android.com Subject: Re: [PATCH 06/14] KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits Message-ID: References: <20210719104735.3681732-1-qperret@google.com> <20210719104735.3681732-7-qperret@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_033012_464339_EEEA59A9 X-CRM114-Status: GOOD ( 23.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Fuad, On Tuesday 20 Jul 2021 at 11:17:03 (+0100), Fuad Tabba wrote: > Hi Quentin, > > > On Mon, Jul 19, 2021 at 11:47 AM Quentin Perret wrote: > > > > The current hypervisor stage-1 mapping code doesn't allow changing an > > existing valid mapping. Relax this condition by allowing changes that > > only target ignored bits, as that will soon be needed to annotate shared > > pages. > > > > Signed-off-by: Quentin Perret > > --- > > arch/arm64/kvm/hyp/pgtable.c | 18 ++++++++++++++++-- > > 1 file changed, 16 insertions(+), 2 deletions(-) > > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index a0ac8c2bc174..34cf67997a82 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -362,6 +362,17 @@ static int hyp_set_prot_attr(enum kvm_pgtable_prot prot, kvm_pte_t *ptep) > > return 0; > > } > > > > +static bool hyp_pte_needs_update(kvm_pte_t old, kvm_pte_t new) > > +{ > > + if (old == new) > > + return false; > > + > > + if (!kvm_pte_valid(old)) > > + return true; > > + > > + return !WARN_ON((old ^ new) & ~KVM_PTE_LEAF_ATTR_IGNORED); > > Wouldn't this return false if both ignored and non-ignored bits were > different, or is that not possible (judging by the WARN_ON)? Correct, but that is intentional, see below ;) > If it is, then it would need an update, wouldn't it? Maybe, but if you look at what the existing code does, we do skip the update if the old mapping is valid and not equal to new. So I kept the behaviour as close as possible to this -- if you change any bits outside of SW bits you get a WARN and we skip the update, as we already do today. But if you touch only SW bits and nothing else, then I let the update go through. That said, I don't think warning and then proceeding to update would be terribly wrong, it's just that a change of behaviour felt a bit unnecessary for this particular patch. Thanks, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FE7DC07E9B for ; Tue, 20 Jul 2021 10:32:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AC0561003 for ; Tue, 20 Jul 2021 10:32:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237880AbhGTJwK (ORCPT ); Tue, 20 Jul 2021 05:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237623AbhGTJtf (ORCPT ); Tue, 20 Jul 2021 05:49:35 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 789D2C061762 for ; Tue, 20 Jul 2021 03:30:12 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id l17-20020a05600c1d11b029021f84fcaf75so1190022wms.1 for ; Tue, 20 Jul 2021 03:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yyHhpf3IFAZa8+1SI9IG6peKhoOSRw9FB1qV/j0MUk8=; b=PhXJaFKOpcy2R87A3f53vk2DTtTJTWwcjsKW3ZIokani62gKo5jR0aptPSmRJ/1fTA 6DTZ6pKoaLfDrl4bXXLSOUBjVLCt7f5wxvv4LQMWoTuqMv0cxIUiPLbommSaffKuRjrP gOmxbCxfzZ7GDSNvdtbSL2rHvQELDImGwvWMlagzTJLTsFQ/sqVZYBhcLuUrRLjO5xop 0BAAZHK1brhUGSN7QZ6Rc5KkPqMNq2A9quWdZax1xJCcYYfyGp0q8AOgjjkeOo8R2jk8 LznC5t+fgx50pyAxYWv1XtdF/r48ir3eBkYYr7JNEU1eMnPFNXlYweVxAtymaGdW9yV1 SiQg== 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=yyHhpf3IFAZa8+1SI9IG6peKhoOSRw9FB1qV/j0MUk8=; b=tG4P+rwgKQUHtIm8It+OPE+ARlxEbhafZwmfKoXbKFNouznVjlDiv7IpvrGpwOxfQK Vpw4pspN33xaUPtzRScvoy+StiSuPkxVKh1H2D5Jyt7Jj0rTyHpTKMQ19q2NS6hbjnBe J5btQ9YMx43Dlit2wwkBSb7gyvjlDtMr1qnRIwZf2/LQ8O5sS0OTRVvzf8ItQYfyvMS1 qASD5eQXQjgnUIfgbAo+Tj6K5RHQaR3tFYFDtStrVVzYbPtR7u/zpjsFPPS1Qt3kCK7j /xrqB2FYhS4TP8Rox2xjntQa3HGzP3FIRDqNBoIKjZ7U08K4fGQkc52BOS7R8n7LGeMn lN/Q== X-Gm-Message-State: AOAM532vbTs+QCRLn6Y/5QdrCQKREpOrzwNaj5lcQ8nQlQkb9IZRZYbu 2pw50yv2qYgsCd0U/j2AUiWkDA== X-Google-Smtp-Source: ABdhPJzn7ppEiI6BziSUJrI9AZI83z3s8BqsMlMXuRgHmlK8PB4VVXduDhaZmxWobhXPrKosB7ng7A== X-Received: by 2002:a05:600c:2255:: with SMTP id a21mr30864834wmm.90.1626777010977; Tue, 20 Jul 2021 03:30:10 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:83e0:11ac:c870:2b97]) by smtp.gmail.com with ESMTPSA id w15sm2558095wmi.3.2021.07.20.03.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 03:30:10 -0700 (PDT) Date: Tue, 20 Jul 2021 11:30:07 +0100 From: Quentin Perret To: Fuad Tabba Cc: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, dbrazdil@google.com, kernel-team@android.com Subject: Re: [PATCH 06/14] KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits Message-ID: References: <20210719104735.3681732-1-qperret@google.com> <20210719104735.3681732-7-qperret@google.com> 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 Hi Fuad, On Tuesday 20 Jul 2021 at 11:17:03 (+0100), Fuad Tabba wrote: > Hi Quentin, > > > On Mon, Jul 19, 2021 at 11:47 AM Quentin Perret wrote: > > > > The current hypervisor stage-1 mapping code doesn't allow changing an > > existing valid mapping. Relax this condition by allowing changes that > > only target ignored bits, as that will soon be needed to annotate shared > > pages. > > > > Signed-off-by: Quentin Perret > > --- > > arch/arm64/kvm/hyp/pgtable.c | 18 ++++++++++++++++-- > > 1 file changed, 16 insertions(+), 2 deletions(-) > > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index a0ac8c2bc174..34cf67997a82 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -362,6 +362,17 @@ static int hyp_set_prot_attr(enum kvm_pgtable_prot prot, kvm_pte_t *ptep) > > return 0; > > } > > > > +static bool hyp_pte_needs_update(kvm_pte_t old, kvm_pte_t new) > > +{ > > + if (old == new) > > + return false; > > + > > + if (!kvm_pte_valid(old)) > > + return true; > > + > > + return !WARN_ON((old ^ new) & ~KVM_PTE_LEAF_ATTR_IGNORED); > > Wouldn't this return false if both ignored and non-ignored bits were > different, or is that not possible (judging by the WARN_ON)? Correct, but that is intentional, see below ;) > If it is, then it would need an update, wouldn't it? Maybe, but if you look at what the existing code does, we do skip the update if the old mapping is valid and not equal to new. So I kept the behaviour as close as possible to this -- if you change any bits outside of SW bits you get a WARN and we skip the update, as we already do today. But if you touch only SW bits and nothing else, then I let the update go through. That said, I don't think warning and then proceeding to update would be terribly wrong, it's just that a change of behaviour felt a bit unnecessary for this particular patch. Thanks, Quentin