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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 4D0F5C07E95 for ; Tue, 20 Jul 2021 11:05:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2984C61175 for ; Tue, 20 Jul 2021 11:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238201AbhGTKZJ (ORCPT ); Tue, 20 Jul 2021 06:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238457AbhGTKT0 (ORCPT ); Tue, 20 Jul 2021 06:19:26 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 257AFC061574 for ; Tue, 20 Jul 2021 04:00:05 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id s23so8357629oiw.12 for ; Tue, 20 Jul 2021 04:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FVn1SYmkQB3M7v69VF2he/NUlW4fKKcfsWY+DKqff6A=; b=Wy82mBov5LjHgcaRRiO3uSMxaLw2FeoKQvcia10TJnBdtBGL9IZSGjxDGX5omGEgDT nJh+G6Jfrn8+kvbeqa0NNd4uBsEq6fmqDFBP3pSD0fKZVNjsIB+SGAEEDPxzzPltefb4 TbrGVgW+jrLjVChYoTUTA01fM0N3fPz6u2SHtPCZaKkDO9XgnJAZlGRfrhShxAb3WRcA KoGRFzcIC1HYR8G0Pv8fyy5KMFGFTqWbp33gLJ1HMxfFP3D1OVrjOReZ0PoE23EjMw/P BnIsWaeoQZSOTrN7575vP0mrGMcF3D62Z1G684aC+T1NcM5IS6FFk1MvgttlPpmbWWec edlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FVn1SYmkQB3M7v69VF2he/NUlW4fKKcfsWY+DKqff6A=; b=KfDm3XsBs8LcGRKb43xnfhg0SjkKKZPQMb++qILkQ+OSSMslZqxYsG7ap6m6hthMPZ /oAQexB7mLWDn4TJnB+Bw0CPRioqbrBJz8swzNNeY3UqQCZivMvnS1oCJy3PbsC7TG6J CKNH0rPlrDk0RrbW4xelzngifJVm2BWK0OlnglJheRNzvEOew1LbMtz9fecWPrmFQ3ph 3OniarWMmb+OXjz92AnC/qx7prp2ar2KZp850wm1c1TirZn94Osqbu4pDmLdlV7l3IgT bJdDCo4cR7N+ehvICl9dty76ZkcZP/U5+3NMgTDRtoqVexGsJrIal5SvbVqQHZjQGPhZ 4gpw== X-Gm-Message-State: AOAM5339ltD04IedTDeLiJXH2u2LinJIEi8vzlAcmYNITY953BV15xnR RxqBbyIyDdZ9PXJgknsaq2NgiRk5rVQ0pB1x1N0UAw== X-Google-Smtp-Source: ABdhPJwifz6pu5NBhio7NwidX7Z1fxHFB/vsZ48ZpYgUwL+dzCzouBKLdEAxyuGStD1hj4hu7q+1YBk4sq1EMVSS+wg= X-Received: by 2002:a05:6808:5a:: with SMTP id v26mr11589545oic.90.1626778803869; Tue, 20 Jul 2021 04:00:03 -0700 (PDT) MIME-Version: 1.0 References: <20210719104735.3681732-1-qperret@google.com> <20210719104735.3681732-7-qperret@google.com> In-Reply-To: From: Fuad Tabba Date: Tue, 20 Jul 2021 11:59:27 +0100 Message-ID: Subject: Re: [PATCH 06/14] KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits To: Quentin Perret 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Quentin, On Tue, Jul 20, 2021 at 11:30 AM 'Quentin Perret' via kernel-team wrote: > > 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 for the clarification. It makes sense to preserve the existing behavior, but I was wondering if a comment would be good, describing what merits a "needs update"? Cheers, /fuad > Thanks, > Quentin > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. > 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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 E58AAC07E95 for ; Tue, 20 Jul 2021 11:00:11 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 586AD6113C for ; Tue, 20 Jul 2021 11:00:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 586AD6113C 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 B183349E57; Tue, 20 Jul 2021 07:00:10 -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 Im7UQJa4kTdI; Tue, 20 Jul 2021 07:00:09 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 95E214B0B5; Tue, 20 Jul 2021 07:00:09 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 89D7949E57 for ; Tue, 20 Jul 2021 07:00:08 -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 IbhXzk3LUhiN for ; Tue, 20 Jul 2021 07:00:05 -0400 (EDT) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 0BB5B4B0B5 for ; Tue, 20 Jul 2021 07:00:04 -0400 (EDT) Received: by mail-oi1-f178.google.com with SMTP id w194so24083015oie.5 for ; Tue, 20 Jul 2021 04:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FVn1SYmkQB3M7v69VF2he/NUlW4fKKcfsWY+DKqff6A=; b=Wy82mBov5LjHgcaRRiO3uSMxaLw2FeoKQvcia10TJnBdtBGL9IZSGjxDGX5omGEgDT nJh+G6Jfrn8+kvbeqa0NNd4uBsEq6fmqDFBP3pSD0fKZVNjsIB+SGAEEDPxzzPltefb4 TbrGVgW+jrLjVChYoTUTA01fM0N3fPz6u2SHtPCZaKkDO9XgnJAZlGRfrhShxAb3WRcA KoGRFzcIC1HYR8G0Pv8fyy5KMFGFTqWbp33gLJ1HMxfFP3D1OVrjOReZ0PoE23EjMw/P BnIsWaeoQZSOTrN7575vP0mrGMcF3D62Z1G684aC+T1NcM5IS6FFk1MvgttlPpmbWWec edlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FVn1SYmkQB3M7v69VF2he/NUlW4fKKcfsWY+DKqff6A=; b=kBA2TTskBVtWkM8hV40YO/xc1UVWr73uP+DPTKtlOZQCX0djYcem0nUai0XWf4gcR/ vhZPEs5nS4GxVh/QXnKZKZ2g6Vm+uNT6O5FoSIpjzPg26xTDpIVmgO+vSjcMY/aQlTYZ bmUclU0s81acutPpVtl+s94XKbnWgHDkgQ6kHcUEe1kb494K7VzQkTN8guBqma4PV4E6 mSxgabcqpGQ0dnRHyhwsWdkcR0qeoHq+MSeE1deh/S2ro8mwtaiTEDiAqUomr0mmy8/F POALjQDrFvjAX9yIMTMOYQ2/5juEAkBi4vUraYb9BX5AKbaTAwdFd92Vj4cUJUwTIa6H v9DA== X-Gm-Message-State: AOAM530XBmVhgPb03vVHn+rzbdHwFuxGVHm4+RG6TT+5qHEImpLTyH/u A2gh0PM1+FNZjPfS2GVkciA19mJBmJifyf3HUHmQPg== X-Google-Smtp-Source: ABdhPJwifz6pu5NBhio7NwidX7Z1fxHFB/vsZ48ZpYgUwL+dzCzouBKLdEAxyuGStD1hj4hu7q+1YBk4sq1EMVSS+wg= X-Received: by 2002:a05:6808:5a:: with SMTP id v26mr11589545oic.90.1626778803869; Tue, 20 Jul 2021 04:00:03 -0700 (PDT) MIME-Version: 1.0 References: <20210719104735.3681732-1-qperret@google.com> <20210719104735.3681732-7-qperret@google.com> In-Reply-To: From: Fuad Tabba Date: Tue, 20 Jul 2021 11:59:27 +0100 Message-ID: Subject: Re: [PATCH 06/14] KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits To: Quentin Perret 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 Quentin, On Tue, Jul 20, 2021 at 11:30 AM 'Quentin Perret' via kernel-team wrote: > > 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 for the clarification. It makes sense to preserve the existing behavior, but I was wondering if a comment would be good, describing what merits a "needs update"? Cheers, /fuad > Thanks, > Quentin > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. > _______________________________________________ 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=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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 55AB4C07E95 for ; Tue, 20 Jul 2021 11:01:51 +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 290826113C for ; Tue, 20 Jul 2021 11:01:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 290826113C 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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=k4wRMrNk+qVi3xH8D+YJKz9eTlpXPbVWlfAe+6c8n4Y=; b=31gQEn3s1l4yn2 SW1KjocRX/1ZBNqHkwAf/6e1gC67i28+bKnTLVfWjrAdfNaIfJeYT0GNvDu76ZxqfQkg5qDn1lKLf 7Av0JTXX8ISPMDe3csHcLrnCjIeT1Z+2NjhbzT1tlrUEzP0Is29FyFig/g1MhE9sHwTwmA9ka8874 57GdrilsXV705EPueiFu1zEpThgVhyR8rS3K+4As7vkLpucwu5bN11qoRJk0jm6CgJSqSIeiSo4NZ Qykpe22Q5qMhXcaG/LHIBtjcJpYXTjkjnH9ZgIyLUgzAQVaQ2wsWPxJD9cIZPaE+Ij0qOGCoR9WaX JVxT0a4IfCHC/hd52vcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5nTt-00Cav6-NW; Tue, 20 Jul 2021 11:00:09 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5nTp-00Caul-Rx for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 11:00:07 +0000 Received: by mail-oi1-x234.google.com with SMTP id c197so24025987oib.11 for ; Tue, 20 Jul 2021 04:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FVn1SYmkQB3M7v69VF2he/NUlW4fKKcfsWY+DKqff6A=; b=Wy82mBov5LjHgcaRRiO3uSMxaLw2FeoKQvcia10TJnBdtBGL9IZSGjxDGX5omGEgDT nJh+G6Jfrn8+kvbeqa0NNd4uBsEq6fmqDFBP3pSD0fKZVNjsIB+SGAEEDPxzzPltefb4 TbrGVgW+jrLjVChYoTUTA01fM0N3fPz6u2SHtPCZaKkDO9XgnJAZlGRfrhShxAb3WRcA KoGRFzcIC1HYR8G0Pv8fyy5KMFGFTqWbp33gLJ1HMxfFP3D1OVrjOReZ0PoE23EjMw/P BnIsWaeoQZSOTrN7575vP0mrGMcF3D62Z1G684aC+T1NcM5IS6FFk1MvgttlPpmbWWec edlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FVn1SYmkQB3M7v69VF2he/NUlW4fKKcfsWY+DKqff6A=; b=ZDYi+7JLV0XX75eppitkL0gIhZ7U6IZRMls3KSkKzy9AtNBJUhWXLFJ8REf5fqC73r jd+rdbYDAYXNt5rxpApl3o2bwmKImo7SCYCxfs80C2wuOVQhI3h8/SomY2/5XPax3ox9 VAJ31muJUhO0oKg2H6TRvLqKexIQ91FypgnnfuBr+Jb+mbpQunNKyxSND8ttlkkcZzP1 NHdy6gUFFvCllR8ehFh08n5k1Gqui805x/6caDPPPPPST+vsrBexlYViLrd1kBaUAtBL zItnPMPO+5BD9pj/6D7W54cSAAxalSv9PGd2KxCptmzF/itiS+Tl4MGapP34Bv1get9P N6XA== X-Gm-Message-State: AOAM532U2byn0YXH2XzXQzEKVaWy+RlMy+ws3D5itOtLCU8AvcYje/n7 P1XTQ8KUHBywEalOF1PXWAvflBbqTm9eC2OC7+/ZOA== X-Google-Smtp-Source: ABdhPJwifz6pu5NBhio7NwidX7Z1fxHFB/vsZ48ZpYgUwL+dzCzouBKLdEAxyuGStD1hj4hu7q+1YBk4sq1EMVSS+wg= X-Received: by 2002:a05:6808:5a:: with SMTP id v26mr11589545oic.90.1626778803869; Tue, 20 Jul 2021 04:00:03 -0700 (PDT) MIME-Version: 1.0 References: <20210719104735.3681732-1-qperret@google.com> <20210719104735.3681732-7-qperret@google.com> In-Reply-To: From: Fuad Tabba Date: Tue, 20 Jul 2021 11:59:27 +0100 Message-ID: Subject: Re: [PATCH 06/14] KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits To: Quentin Perret 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_040005_978374_2C4E4F82 X-CRM114-Status: GOOD ( 31.11 ) 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 Quentin, On Tue, Jul 20, 2021 at 11:30 AM 'Quentin Perret' via kernel-team wrote: > > 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 for the clarification. It makes sense to preserve the existing behavior, but I was wondering if a comment would be good, describing what merits a "needs update"? Cheers, /fuad > Thanks, > Quentin > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel