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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 D17E1C4708F for ; Wed, 2 Jun 2021 10:51:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9A3B613AE for ; Wed, 2 Jun 2021 10:51:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbhFBKw6 (ORCPT ); Wed, 2 Jun 2021 06:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbhFBKvq (ORCPT ); Wed, 2 Jun 2021 06:51:46 -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 1DB91C061763 for ; Wed, 2 Jun 2021 03:49:55 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id l11-20020a05600c4f0bb029017a7cd488f5so1434215wmq.0 for ; Wed, 02 Jun 2021 03:49:55 -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=iBPgoenc4+VXFgVYv4Mb1skeP6ikfbF6DUFZDuY5ah0=; b=qMBk9o3bcP5GtSnrBEjM+uWb62KPrE2rQIg+ZFejyIJ7KDc7EuHbWv6Ier5kZTigIR 5mXf3/3MmGJskgrxiaqGw4px5jD+G+hWfPNKX0VB3Q90xVaVC9W2ub5I3+4rYkIr8C6L chxtaxQI8hnb/YGqTd3MdhmSJpqeWk8UrZcTCfv9IvFWRmdLQcBX8tWbGKN4KBvbOEJ+ EETPihJUuo8Fv747IZjxQehWVelRce/UwRVy83oJFO+hbvPTHpQi+IVjW3yMXgmJzK+H F27yNQMNOwh5K9XYmMwdm2gEuDDNQoEjQcctogIZhgnGP8eVl1utqqHRhFOj1a+KnMcs NNSw== 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=iBPgoenc4+VXFgVYv4Mb1skeP6ikfbF6DUFZDuY5ah0=; b=HmxkOjF8yAr9csDjpw/562y6ckUuGjCnKgblsR3Nf6Cbc6Lc162ZzMfxu9YNBtMxHs dbcqR3J+IgHIOyU8avDXYmsn/cjK7Yqf9e/67HpzARxLcsP6lGFMmD8WNxKO6wIQXl4e YHsz2wjpNYZLxcnQ15XRca5/2AtZ5DA2IBzwir2N7C5xRwdVe6fw5VCRyGWXZutUxCw0 YY5g8o6ZO2A8BOcSobdyi7PF/QlIffnAKPaychmfNZX6Rwy05BMjLjE8FctnuOrgpRjk pNnv5M/h784m2Vqt40nUzwStW/ygmSSr/43SoMJvoLZtfqJeZvt+IH69eAPtiDQP9vcE IFMQ== X-Gm-Message-State: AOAM532WEZPNd1Em9Dk9ECAm/Mej+rJWtH6IYTnYZqyoe/mTFdIhYkzo hd/oKU1kBIwLda6Z4kmjrRRNwQ== X-Google-Smtp-Source: ABdhPJxJX3H2bjJ6ZWWGMvygaz55JMVzxmecp5Rkf4VcZ3RHRl9KDTV+xgJcccrQmFsHPJCg9w3A/w== X-Received: by 2002:a7b:cc8f:: with SMTP id p15mr4585583wma.111.1622630993639; Wed, 02 Jun 2021 03:49:53 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id a123sm2687146wmd.2.2021.06.02.03.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:49:53 -0700 (PDT) Date: Wed, 2 Jun 2021 10:49:50 +0000 From: Quentin Perret To: Marc Zyngier Cc: Yanan Wang , Will Deacon , Alexandru Elisei , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , James Morse , Julien Thierry , Suzuki K Poulose , Gavin Shan , wanghaibin.wang@huawei.com, zhukeqian1@huawei.com, yuzenghui@huawei.com Subject: Re: [PATCH v5 2/6] KVM: arm64: Move D-cache flush to the fault handlers Message-ID: References: <20210415115032.35760-1-wangyanan55@huawei.com> <20210415115032.35760-3-wangyanan55@huawei.com> <877djc1sca.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877djc1sca.wl-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 02 Jun 2021 at 11:19:49 (+0100), Marc Zyngier wrote: > On Thu, 15 Apr 2021 12:50:28 +0100, > > @@ -583,6 +589,7 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > > { > > kvm_pte_t new, old = *ptep; > > u64 granule = kvm_granule_size(level), phys = data->phys; > > + struct kvm_pgtable *pgt = data->mmu->pgt; > > struct kvm_pgtable_mm_ops *mm_ops = data->mm_ops; > > > > if (!kvm_block_mapping_supported(addr, end, phys, level)) > > @@ -606,6 +613,13 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > > stage2_put_pte(ptep, data->mmu, addr, level, mm_ops); > > } > > > > + /* Perform CMOs before installation of the guest stage-2 PTE */ > > + if (pgt->flags & KVM_PGTABLE_S2_GUEST) { > > + if (stage2_pte_cacheable(pgt, new) && !stage2_has_fwb(pgt)) > > + __flush_dcache_area(mm_ops->phys_to_virt(phys), > > + granule); > > + } > > Rather than this, why not provide new callbacks in mm_ops, even if we > have to provide one that is specific to guests (and let the protected > stuff do its own thing)? Ack, an optional callback in the mm_ops sounds much nicer. > One thing I really dislike though is that the page-table code is > starting to be littered with things that are not directly related to > page tables. We are re-creating the user_mem_abort() mess in a > different place. +1, we should probably keep the page-table code as close as possible to a standalone and architecturally-compliant library as opposed to a mess of unrelated logic, simply because that will lead to a cleaner and more maintainable design in the long run, and because that will ease the interoperability with EL2 in protected mode. Thanks, Quentin 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=-8.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,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 58A9BC47083 for ; Wed, 2 Jun 2021 10:50:06 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id CE3F36023F for ; Wed, 2 Jun 2021 10:50:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE3F36023F 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 4208A406E0; Wed, 2 Jun 2021 06:50:05 -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 bRCUHXseJayR; Wed, 2 Jun 2021 06:50:00 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A8D8940877; Wed, 2 Jun 2021 06:50:00 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 826DF4086A for ; Wed, 2 Jun 2021 06:49:59 -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 lbwYIMNVNxkY for ; Wed, 2 Jun 2021 06:49:54 -0400 (EDT) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id BEED3406E0 for ; Wed, 2 Jun 2021 06:49:54 -0400 (EDT) Received: by mail-wm1-f47.google.com with SMTP id t4-20020a1c77040000b029019d22d84ebdso3469553wmi.3 for ; Wed, 02 Jun 2021 03:49:54 -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=iBPgoenc4+VXFgVYv4Mb1skeP6ikfbF6DUFZDuY5ah0=; b=qMBk9o3bcP5GtSnrBEjM+uWb62KPrE2rQIg+ZFejyIJ7KDc7EuHbWv6Ier5kZTigIR 5mXf3/3MmGJskgrxiaqGw4px5jD+G+hWfPNKX0VB3Q90xVaVC9W2ub5I3+4rYkIr8C6L chxtaxQI8hnb/YGqTd3MdhmSJpqeWk8UrZcTCfv9IvFWRmdLQcBX8tWbGKN4KBvbOEJ+ EETPihJUuo8Fv747IZjxQehWVelRce/UwRVy83oJFO+hbvPTHpQi+IVjW3yMXgmJzK+H F27yNQMNOwh5K9XYmMwdm2gEuDDNQoEjQcctogIZhgnGP8eVl1utqqHRhFOj1a+KnMcs NNSw== 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=iBPgoenc4+VXFgVYv4Mb1skeP6ikfbF6DUFZDuY5ah0=; b=OKPJjT5uvzxMC5ZnMf3loZvZWfPYuM9ixqAle21rTzERPIU/l9kyYcf3r323EPMImu GVZ3/xoI94wQGGWFgaMVL1jNtQYuRsYgivMKJbXSTKR7tEuj3SYEFIJFIYdLuVvxzp0k /O18AmQgC7pznLjGB1jApQFCIuZBZXhxqg9DV4VGt+qDvMC2PMS6cSQxaWN1eLxM+8HN G7Bjc2VOcJzyiEiFaod/iCfPt/hnarbKa2wzpmY25wE/Y9nDnJuSrg01bePoGtkAVLuf Q2j2wwCTKbb4Wy2TgKFGlA0VqkHNEmO/dX2ssE3RclJC0x5iAuT9NOqjqaYVFl5Ce37u 1rcQ== X-Gm-Message-State: AOAM531egivSbpBs9e4woBosSeCPB+osj6SchDApmD6hRc9/+sntLHHd aope5UjWMvvRIyn4UdpevKAHfg== X-Google-Smtp-Source: ABdhPJxJX3H2bjJ6ZWWGMvygaz55JMVzxmecp5Rkf4VcZ3RHRl9KDTV+xgJcccrQmFsHPJCg9w3A/w== X-Received: by 2002:a7b:cc8f:: with SMTP id p15mr4585583wma.111.1622630993639; Wed, 02 Jun 2021 03:49:53 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id a123sm2687146wmd.2.2021.06.02.03.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:49:53 -0700 (PDT) Date: Wed, 2 Jun 2021 10:49:50 +0000 From: Quentin Perret To: Marc Zyngier Subject: Re: [PATCH v5 2/6] KVM: arm64: Move D-cache flush to the fault handlers Message-ID: References: <20210415115032.35760-1-wangyanan55@huawei.com> <20210415115032.35760-3-wangyanan55@huawei.com> <877djc1sca.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <877djc1sca.wl-maz@kernel.org> Cc: kvm@vger.kernel.org, Will Deacon , linux-kernel@vger.kernel.org, Catalin Marinas , 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 On Wednesday 02 Jun 2021 at 11:19:49 (+0100), Marc Zyngier wrote: > On Thu, 15 Apr 2021 12:50:28 +0100, > > @@ -583,6 +589,7 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > > { > > kvm_pte_t new, old = *ptep; > > u64 granule = kvm_granule_size(level), phys = data->phys; > > + struct kvm_pgtable *pgt = data->mmu->pgt; > > struct kvm_pgtable_mm_ops *mm_ops = data->mm_ops; > > > > if (!kvm_block_mapping_supported(addr, end, phys, level)) > > @@ -606,6 +613,13 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > > stage2_put_pte(ptep, data->mmu, addr, level, mm_ops); > > } > > > > + /* Perform CMOs before installation of the guest stage-2 PTE */ > > + if (pgt->flags & KVM_PGTABLE_S2_GUEST) { > > + if (stage2_pte_cacheable(pgt, new) && !stage2_has_fwb(pgt)) > > + __flush_dcache_area(mm_ops->phys_to_virt(phys), > > + granule); > > + } > > Rather than this, why not provide new callbacks in mm_ops, even if we > have to provide one that is specific to guests (and let the protected > stuff do its own thing)? Ack, an optional callback in the mm_ops sounds much nicer. > One thing I really dislike though is that the page-table code is > starting to be littered with things that are not directly related to > page tables. We are re-creating the user_mem_abort() mess in a > different place. +1, we should probably keep the page-table code as close as possible to a standalone and architecturally-compliant library as opposed to a mess of unrelated logic, simply because that will lead to a cleaner and more maintainable design in the long run, and because that will ease the interoperability with EL2 in protected mode. 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=-9.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, 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 78077C4708F for ; Wed, 2 Jun 2021 10:52:46 +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 43279613AD for ; Wed, 2 Jun 2021 10:52:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43279613AD 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=b65BgRZ0aekeTqymLAegQZhMLk6ilhRGmi22nfBskI8=; b=ZeN5+dw3CMIq9B OOt8Qpf9Owx+AxzzbgWEtvNGgIWxZQkRRPJTa06PNE6bB0X0+ya8toCnBCgb0F5OapzvhxcP5yDSE sSSzWT8/LHW94ME/w8t7gT584SIemxgXyLWUtOL2LZRpqd8i/3rDGVZhmHiNWdjvqLV3f6PTJG/Pk eG1REbEcGycBVlS53yNA+N632T7irg8qScMkn7NSSDmYLl0YftPv7f2EaH6AHxZY6GyKfSXP07ftq 4Fjh1QLZSzX+929CT7FSR/2oQVo8IWbqezHrV62ustPjQNOwPHC7zhnktrTBIIA0OzE7fmBehHINC WJyqjBLBU5VB6NUfVLyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loOSN-003SrW-Oz; Wed, 02 Jun 2021 10:50:41 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loORf-003Sb2-8Q for linux-arm-kernel@lists.infradead.org; Wed, 02 Jun 2021 10:49:58 +0000 Received: by mail-wm1-x333.google.com with SMTP id g204so963689wmf.5 for ; Wed, 02 Jun 2021 03:49:54 -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=iBPgoenc4+VXFgVYv4Mb1skeP6ikfbF6DUFZDuY5ah0=; b=qMBk9o3bcP5GtSnrBEjM+uWb62KPrE2rQIg+ZFejyIJ7KDc7EuHbWv6Ier5kZTigIR 5mXf3/3MmGJskgrxiaqGw4px5jD+G+hWfPNKX0VB3Q90xVaVC9W2ub5I3+4rYkIr8C6L chxtaxQI8hnb/YGqTd3MdhmSJpqeWk8UrZcTCfv9IvFWRmdLQcBX8tWbGKN4KBvbOEJ+ EETPihJUuo8Fv747IZjxQehWVelRce/UwRVy83oJFO+hbvPTHpQi+IVjW3yMXgmJzK+H F27yNQMNOwh5K9XYmMwdm2gEuDDNQoEjQcctogIZhgnGP8eVl1utqqHRhFOj1a+KnMcs NNSw== 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=iBPgoenc4+VXFgVYv4Mb1skeP6ikfbF6DUFZDuY5ah0=; b=tKLbjaNmT9LYHOCyb+DrIbN6fOJtG+UOg23au+JWauofpxpLTtzQ0G4SC8IBLSVi7X IRN1KSS7PRCIwbgYH6tpGeJLpqDRfyGu33SmLbZ9TGQy69wH2uvIN6xH8myRZ/yfYP6M ETke05u8sxifVbCL2B080RAmH2/nWycHFGBiSLPm3apPg9tVzdjVbpiD3X3SBv6zfcHs gqPwAKK4ktGNJi2wYrN3ieykuUwmyqDvb/wk8TyM4BpL3ROuE+HyjplzKVksBH5rOhah IG8tFfgzT7LgH2pOagJaGrdWB2v2FMsqbq5tfn/+Pgs1a1VVi7mLil5jh9dM+8AULdTU mrEQ== X-Gm-Message-State: AOAM531FzZznEZzBGYxvAb7HJNAWHr+mo7NBV1s70Us3vM2fQD2bS+Kg 6MsRgXFpKujJqpFDT0UXDRm7eg== X-Google-Smtp-Source: ABdhPJxJX3H2bjJ6ZWWGMvygaz55JMVzxmecp5Rkf4VcZ3RHRl9KDTV+xgJcccrQmFsHPJCg9w3A/w== X-Received: by 2002:a7b:cc8f:: with SMTP id p15mr4585583wma.111.1622630993639; Wed, 02 Jun 2021 03:49:53 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id a123sm2687146wmd.2.2021.06.02.03.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:49:53 -0700 (PDT) Date: Wed, 2 Jun 2021 10:49:50 +0000 From: Quentin Perret To: Marc Zyngier Cc: Yanan Wang , Will Deacon , Alexandru Elisei , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , James Morse , Julien Thierry , Suzuki K Poulose , Gavin Shan , wanghaibin.wang@huawei.com, zhukeqian1@huawei.com, yuzenghui@huawei.com Subject: Re: [PATCH v5 2/6] KVM: arm64: Move D-cache flush to the fault handlers Message-ID: References: <20210415115032.35760-1-wangyanan55@huawei.com> <20210415115032.35760-3-wangyanan55@huawei.com> <877djc1sca.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <877djc1sca.wl-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210602_034955_363787_8842D0EF X-CRM114-Status: GOOD ( 16.99 ) 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 On Wednesday 02 Jun 2021 at 11:19:49 (+0100), Marc Zyngier wrote: > On Thu, 15 Apr 2021 12:50:28 +0100, > > @@ -583,6 +589,7 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > > { > > kvm_pte_t new, old = *ptep; > > u64 granule = kvm_granule_size(level), phys = data->phys; > > + struct kvm_pgtable *pgt = data->mmu->pgt; > > struct kvm_pgtable_mm_ops *mm_ops = data->mm_ops; > > > > if (!kvm_block_mapping_supported(addr, end, phys, level)) > > @@ -606,6 +613,13 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > > stage2_put_pte(ptep, data->mmu, addr, level, mm_ops); > > } > > > > + /* Perform CMOs before installation of the guest stage-2 PTE */ > > + if (pgt->flags & KVM_PGTABLE_S2_GUEST) { > > + if (stage2_pte_cacheable(pgt, new) && !stage2_has_fwb(pgt)) > > + __flush_dcache_area(mm_ops->phys_to_virt(phys), > > + granule); > > + } > > Rather than this, why not provide new callbacks in mm_ops, even if we > have to provide one that is specific to guests (and let the protected > stuff do its own thing)? Ack, an optional callback in the mm_ops sounds much nicer. > One thing I really dislike though is that the page-table code is > starting to be littered with things that are not directly related to > page tables. We are re-creating the user_mem_abort() mess in a > different place. +1, we should probably keep the page-table code as close as possible to a standalone and architecturally-compliant library as opposed to a mess of unrelated logic, simply because that will lead to a cleaner and more maintainable design in the long run, and because that will ease the interoperability with EL2 in protected mode. Thanks, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel