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=-5.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 120C2C1B0D9 for ; Tue, 8 Dec 2020 09:52:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C64CC233FA for ; Tue, 8 Dec 2020 09:52:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728703AbgLHJvw (ORCPT ); Tue, 8 Dec 2020 04:51:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbgLHJvv (ORCPT ); Tue, 8 Dec 2020 04:51:51 -0500 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E44DC0613D6 for ; Tue, 8 Dec 2020 01:51:36 -0800 (PST) Received: by mail-il1-x144.google.com with SMTP id b8so14950098ila.13 for ; Tue, 08 Dec 2020 01:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lICLkvZe3ToayMLnSKCmLUo/K0jAtkBksOUim1ibfBY=; b=VN5ue7ud1agT4R98hMSjewuu2LrhcoCORuoWMvUQhM7WIE3bjCyU1RI+UgBzBQJvSa DeJL9Vj1lqwp73sDe7qAZCQGzPaV38h3Ak992sNOyFdK9N7Dm3uDnwV9u6kk0wf5oLPB uO9PIK/I6Z6GNd0ccNasHlSEBZ2nO8mOiEDhptmjoIfoInncgQvQccrrwtJUCDzYB30P Cy88O7m1MgujhOWND/z3r645zM41SRjSULqc4yb+GHroCLcQnzvhXbpI+hCbEMx3n4TS sc2KpyZHMAx+YZQUcK9AZRa23RmwmxNGJ+uTYKUKf5/xrlbqSZ0h5j00nmz/ND5XE8Ei fmsA== 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=lICLkvZe3ToayMLnSKCmLUo/K0jAtkBksOUim1ibfBY=; b=qbeyQbwQCAwx027JeNiMmWSf7vZQtMm5kuuy5KjMewHOmNBIXyIlBXCCsbsCxKEO1r cHMvBSl9WWWQgZuZ08bqqfpLdPgspIEsRVCPEvs2am/9aPNbeIfSLzkasLyAuCFsT2BZ cIxbfNaRiLedyPoFq4XxcIqEHzsfQYvRe7NxX45uCXTLjtg9TtMHqwslIp7lShR559QS 9VLU4nHIi3P+zoKSaDFea573Gnd+xHxVCj4OpocibVCSs6IaKAE/6miPoe/7hrKWqURQ Du+/qvxVwvDDo1BMXzaNQHAEYNjmnEeG56GQPYEEqPix+aJRCtBcQQ2vRMLvdQ66kWzY YJMw== X-Gm-Message-State: AOAM533sO/anQH9qK4sUfpPoU7hBrO0GYRdP9OWwEn5J2PuVb78iUy+Q aSIR7BYUkZ2iyA1k5mnXokc2JNorxjZr9GOZ1Oy7 X-Google-Smtp-Source: ABdhPJwGCf1kaRkx/7nAHZDQ/wyyZFTaySkgpZz9i3yxGq+ecwqhoNO47BJ7xfQcGlhhOsqN9O7eP92qE6AOnkqP+v4= X-Received: by 2002:a92:b6c3:: with SMTP id m64mr15859393ill.23.1607421095680; Tue, 08 Dec 2020 01:51:35 -0800 (PST) MIME-Version: 1.0 References: <20201119153901.53705-1-steven.price@arm.com> <20201119184248.4bycy6ouvaxqdiiy@kamzik.brq.redhat.com> <46fd98a2-ee39-0086-9159-b38c406935ab@arm.com> In-Reply-To: <46fd98a2-ee39-0086-9159-b38c406935ab@arm.com> From: Haibo Xu Date: Tue, 8 Dec 2020 17:51:24 +0800 Message-ID: Subject: Re: [PATCH v5 0/2] MTE support for KVM guest To: Steven Price Cc: Marc Zyngier , Andrew Jones , Catalin Marinas , Juan Quintela , Richard Henderson , QEMU Developers , "Dr. David Alan Gilbert" , arm-mail-list , kvmarm , Thomas Gleixner , Will Deacon , Dave Martin , lkml - Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Dec 2020 at 22:48, Steven Price wrote: > > On 04/12/2020 08:25, Haibo Xu wrote: > > On Fri, 20 Nov 2020 at 17:51, Steven Price wrote: > >> > >> On 19/11/2020 19:11, Marc Zyngier wrote: > >>> On 2020-11-19 18:42, Andrew Jones wrote: > >>>> On Thu, Nov 19, 2020 at 03:45:40PM +0000, Peter Maydell wrote: > >>>>> On Thu, 19 Nov 2020 at 15:39, Steven Price wrote: > >>>>>> This series adds support for Arm's Memory Tagging Extension (MTE) to > >>>>>> KVM, allowing KVM guests to make use of it. This builds on the > >>>>> existing > >>>>>> user space support already in v5.10-rc1, see [1] for an overview. > >>>>> > >>>>>> The change to require the VMM to map all guest memory PROT_MTE is > >>>>>> significant as it means that the VMM has to deal with the MTE tags > >>>>> even > >>>>>> if it doesn't care about them (e.g. for virtual devices or if the VMM > >>>>>> doesn't support migration). Also unfortunately because the VMM can > >>>>>> change the memory layout at any time the check for PROT_MTE/VM_MTE has > >>>>>> to be done very late (at the point of faulting pages into stage 2). > >>>>> > >>>>> I'm a bit dubious about requring the VMM to map the guest memory > >>>>> PROT_MTE unless somebody's done at least a sketch of the design > >>>>> for how this would work on the QEMU side. Currently QEMU just > >>>>> assumes the guest memory is guest memory and it can access it > >>>>> without special precautions... > >>>>> > >>>> > >>>> There are two statements being made here: > >>>> > >>>> 1) Requiring the use of PROT_MTE when mapping guest memory may not fit > >>>> QEMU well. > >>>> > >>>> 2) New KVM features should be accompanied with supporting QEMU code in > >>>> order to prove that the APIs make sense. > >>>> > >>>> I strongly agree with (2). While kvmtool supports some quick testing, it > >>>> doesn't support migration. We must test all new features with a migration > >>>> supporting VMM. > >>>> > >>>> I'm not sure about (1). I don't feel like it should be a major problem, > >>>> but (2). > >> > >> (1) seems to be contentious whichever way we go. Either PROT_MTE isn't > >> required in which case it's easy to accidentally screw up migration, or > >> it is required in which case it's difficult to handle normal guest > >> memory from the VMM. I get the impression that probably I should go back > >> to the previous approach - sorry for the distraction with this change. > >> > >> (2) isn't something I'm trying to skip, but I'm limited in what I can do > >> myself so would appreciate help here. Haibo is looking into this. > >> > > > > Hi Steven, > > > > Sorry for the later reply! > > > > I have finished the POC for the MTE migration support with the assumption > > that all the memory is mapped with PROT_MTE. But I got stuck in the test > > with a FVP setup. Previously, I successfully compiled a test case to verify > > the basic function of MTE in a guest. But these days, the re-compiled test > > can't be executed by the guest(very weird). The short plan to verify > > the migration > > is to set the MTE tags on one page in the guest, and try to dump the migrated > > memory contents. > > Hi Haibo, > > Sounds like you are making good progress - thanks for the update. Have > you thought about how the PROT_MTE mappings might work if QEMU itself > were to use MTE? My worry is that we end up with MTE in a guest > preventing QEMU from using MTE itself (because of the PROT_MTE > mappings). I'm hoping QEMU can wrap its use of guest memory in a > sequence which disables tag checking (something similar will be needed > for the "protected VM" use case anyway), but this isn't something I've > looked into. As far as I can see, to map all the guest memory with PROT_MTE in VMM is a little weird, and lots of APIs have to be changed to include this flag. IMHO, it would be better if the KVM can provide new APIs to load/store the guest memory tag which may make it easier to enable the Qemu migration support. > > > I will update the status later next week! > > Great, I look forward to hearing how it goes. > > Thanks, > > Steve 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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 1A247C433FE for ; Tue, 8 Dec 2020 09:56:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 59E1A23A84 for ; Tue, 8 Dec 2020 09:56:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59E1A23A84 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmZjk-0006Xt-Rm for qemu-devel@archiver.kernel.org; Tue, 08 Dec 2020 04:56:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmZen-0004X6-VO for qemu-devel@nongnu.org; Tue, 08 Dec 2020 04:51:41 -0500 Received: from mail-il1-x141.google.com ([2607:f8b0:4864:20::141]:44034) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmZel-0001Wp-4d for qemu-devel@nongnu.org; Tue, 08 Dec 2020 04:51:41 -0500 Received: by mail-il1-x141.google.com with SMTP id r17so14928452ilo.11 for ; Tue, 08 Dec 2020 01:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lICLkvZe3ToayMLnSKCmLUo/K0jAtkBksOUim1ibfBY=; b=VN5ue7ud1agT4R98hMSjewuu2LrhcoCORuoWMvUQhM7WIE3bjCyU1RI+UgBzBQJvSa DeJL9Vj1lqwp73sDe7qAZCQGzPaV38h3Ak992sNOyFdK9N7Dm3uDnwV9u6kk0wf5oLPB uO9PIK/I6Z6GNd0ccNasHlSEBZ2nO8mOiEDhptmjoIfoInncgQvQccrrwtJUCDzYB30P Cy88O7m1MgujhOWND/z3r645zM41SRjSULqc4yb+GHroCLcQnzvhXbpI+hCbEMx3n4TS sc2KpyZHMAx+YZQUcK9AZRa23RmwmxNGJ+uTYKUKf5/xrlbqSZ0h5j00nmz/ND5XE8Ei fmsA== 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=lICLkvZe3ToayMLnSKCmLUo/K0jAtkBksOUim1ibfBY=; b=QSg8cgRrBTdzT9AwSg3/Q0+y4/FP5K3BMQrtj+njcAC5nPhAEVQCv5XQvIFohf/T57 VXCkgIADdNJaMFpFTH48/hUR8bMw14q/eUw4b0LYch4p+Mz9WG0j02ESfciVavOMEC3h oLNaCtse/tiM6RKEyrVZyj2z2InfR4Webum4+NYltGWcsgvG9wkBX1jG+3cEf17ReLXY a+qtD8ltdP32VEMHMsI+6E5onsdmCh8FcrdH3kmMR9JNMy4A/3lyCMJM9pGnFDzqXj1/ JNuXki0yHyWsV6tch1nuaWxhTRzjk3PKswYrG1a/ZyNxkm6f4ANMWl52NQSkv3HiHGuk 7iFQ== X-Gm-Message-State: AOAM532YM6XcsxAGXbeNXKtSG75qXnYkDjToYVfxYuM4OFOAVEKB7JkQ mlDr4m+U81owp5R6HztXoISuL4uAK/ziEMRwt5yK X-Google-Smtp-Source: ABdhPJwGCf1kaRkx/7nAHZDQ/wyyZFTaySkgpZz9i3yxGq+ecwqhoNO47BJ7xfQcGlhhOsqN9O7eP92qE6AOnkqP+v4= X-Received: by 2002:a92:b6c3:: with SMTP id m64mr15859393ill.23.1607421095680; Tue, 08 Dec 2020 01:51:35 -0800 (PST) MIME-Version: 1.0 References: <20201119153901.53705-1-steven.price@arm.com> <20201119184248.4bycy6ouvaxqdiiy@kamzik.brq.redhat.com> <46fd98a2-ee39-0086-9159-b38c406935ab@arm.com> In-Reply-To: <46fd98a2-ee39-0086-9159-b38c406935ab@arm.com> From: Haibo Xu Date: Tue, 8 Dec 2020 17:51:24 +0800 Message-ID: Subject: Re: [PATCH v5 0/2] MTE support for KVM guest To: Steven Price Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::141; envelope-from=haibo.xu@linaro.org; helo=mail-il1-x141.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jones , lkml - Kernel Mailing List , Juan Quintela , Marc Zyngier , Richard Henderson , QEMU Developers , "Dr. David Alan Gilbert" , Catalin Marinas , Thomas Gleixner , Will Deacon , kvmarm , arm-mail-list , Dave Martin Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Mon, 7 Dec 2020 at 22:48, Steven Price wrote: > > On 04/12/2020 08:25, Haibo Xu wrote: > > On Fri, 20 Nov 2020 at 17:51, Steven Price wrote: > >> > >> On 19/11/2020 19:11, Marc Zyngier wrote: > >>> On 2020-11-19 18:42, Andrew Jones wrote: > >>>> On Thu, Nov 19, 2020 at 03:45:40PM +0000, Peter Maydell wrote: > >>>>> On Thu, 19 Nov 2020 at 15:39, Steven Price wrote: > >>>>>> This series adds support for Arm's Memory Tagging Extension (MTE) to > >>>>>> KVM, allowing KVM guests to make use of it. This builds on the > >>>>> existing > >>>>>> user space support already in v5.10-rc1, see [1] for an overview. > >>>>> > >>>>>> The change to require the VMM to map all guest memory PROT_MTE is > >>>>>> significant as it means that the VMM has to deal with the MTE tags > >>>>> even > >>>>>> if it doesn't care about them (e.g. for virtual devices or if the VMM > >>>>>> doesn't support migration). Also unfortunately because the VMM can > >>>>>> change the memory layout at any time the check for PROT_MTE/VM_MTE has > >>>>>> to be done very late (at the point of faulting pages into stage 2). > >>>>> > >>>>> I'm a bit dubious about requring the VMM to map the guest memory > >>>>> PROT_MTE unless somebody's done at least a sketch of the design > >>>>> for how this would work on the QEMU side. Currently QEMU just > >>>>> assumes the guest memory is guest memory and it can access it > >>>>> without special precautions... > >>>>> > >>>> > >>>> There are two statements being made here: > >>>> > >>>> 1) Requiring the use of PROT_MTE when mapping guest memory may not fit > >>>> QEMU well. > >>>> > >>>> 2) New KVM features should be accompanied with supporting QEMU code in > >>>> order to prove that the APIs make sense. > >>>> > >>>> I strongly agree with (2). While kvmtool supports some quick testing, it > >>>> doesn't support migration. We must test all new features with a migration > >>>> supporting VMM. > >>>> > >>>> I'm not sure about (1). I don't feel like it should be a major problem, > >>>> but (2). > >> > >> (1) seems to be contentious whichever way we go. Either PROT_MTE isn't > >> required in which case it's easy to accidentally screw up migration, or > >> it is required in which case it's difficult to handle normal guest > >> memory from the VMM. I get the impression that probably I should go back > >> to the previous approach - sorry for the distraction with this change. > >> > >> (2) isn't something I'm trying to skip, but I'm limited in what I can do > >> myself so would appreciate help here. Haibo is looking into this. > >> > > > > Hi Steven, > > > > Sorry for the later reply! > > > > I have finished the POC for the MTE migration support with the assumption > > that all the memory is mapped with PROT_MTE. But I got stuck in the test > > with a FVP setup. Previously, I successfully compiled a test case to verify > > the basic function of MTE in a guest. But these days, the re-compiled test > > can't be executed by the guest(very weird). The short plan to verify > > the migration > > is to set the MTE tags on one page in the guest, and try to dump the migrated > > memory contents. > > Hi Haibo, > > Sounds like you are making good progress - thanks for the update. Have > you thought about how the PROT_MTE mappings might work if QEMU itself > were to use MTE? My worry is that we end up with MTE in a guest > preventing QEMU from using MTE itself (because of the PROT_MTE > mappings). I'm hoping QEMU can wrap its use of guest memory in a > sequence which disables tag checking (something similar will be needed > for the "protected VM" use case anyway), but this isn't something I've > looked into. As far as I can see, to map all the guest memory with PROT_MTE in VMM is a little weird, and lots of APIs have to be changed to include this flag. IMHO, it would be better if the KVM can provide new APIs to load/store the guest memory tag which may make it easier to enable the Qemu migration support. > > > I will update the status later next week! > > Great, I look forward to hearing how it goes. > > Thanks, > > Steve 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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 9F3A0C4361B for ; Tue, 8 Dec 2020 09:51:44 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 04B7E23A84 for ; Tue, 8 Dec 2020 09:51:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04B7E23A84 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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 3737C4B1C1; Tue, 8 Dec 2020 04:51:43 -0500 (EST) 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=@linaro.org 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 qBv2HSGZ-J6P; Tue, 8 Dec 2020 04:51:41 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D1C0E4B0F5; Tue, 8 Dec 2020 04:51:41 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 640D34B0D9 for ; Tue, 8 Dec 2020 04:51:40 -0500 (EST) 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 UWAJHEcteLqY for ; Tue, 8 Dec 2020 04:51:36 -0500 (EST) Received: from mail-il1-f195.google.com (mail-il1-f195.google.com [209.85.166.195]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 7498C4B0E6 for ; Tue, 8 Dec 2020 04:51:36 -0500 (EST) Received: by mail-il1-f195.google.com with SMTP id j12so7817226ilk.3 for ; Tue, 08 Dec 2020 01:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lICLkvZe3ToayMLnSKCmLUo/K0jAtkBksOUim1ibfBY=; b=VN5ue7ud1agT4R98hMSjewuu2LrhcoCORuoWMvUQhM7WIE3bjCyU1RI+UgBzBQJvSa DeJL9Vj1lqwp73sDe7qAZCQGzPaV38h3Ak992sNOyFdK9N7Dm3uDnwV9u6kk0wf5oLPB uO9PIK/I6Z6GNd0ccNasHlSEBZ2nO8mOiEDhptmjoIfoInncgQvQccrrwtJUCDzYB30P Cy88O7m1MgujhOWND/z3r645zM41SRjSULqc4yb+GHroCLcQnzvhXbpI+hCbEMx3n4TS sc2KpyZHMAx+YZQUcK9AZRa23RmwmxNGJ+uTYKUKf5/xrlbqSZ0h5j00nmz/ND5XE8Ei fmsA== 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=lICLkvZe3ToayMLnSKCmLUo/K0jAtkBksOUim1ibfBY=; b=j50m9t1pLdotLBgPn5D1vY5MatvMTpPfwVdRcOcGsp5RLSUZoOF9kSOPr8KaqD9s2y Q8ylgvH4+rxp6iYa7yoaIOQGrUPiKpZ0wz9UzbXDyauvtsYAMkf0xUQbLrpRP/s6zhUA Z6DsNgXYVKX+Ej8QWS+PoM33Ct37VvqtyCfH08tbyGmlQr9dasli+Va9OjhOoaKsqekx Leng4n9qPBJc0f2r2gquugjBoxZ6QFd0GkaLTzR+EXu2MnKMUR52EoQHFBrIdlQps0ti YgVZ7alek/TYtuLxIhMYbnckVBntSRogz5s4liC/tEp2lCfoJFLJrecghNKdpHB6NrWY lQEg== X-Gm-Message-State: AOAM533+YrfPNhrZTnZe3MxRXzVI+MpEXcdZM67wsM0boj7IFHc1bYtL uMlpIjFhGEU9k56ydTLiNTuAx+pDactJWTqB/++W X-Google-Smtp-Source: ABdhPJwGCf1kaRkx/7nAHZDQ/wyyZFTaySkgpZz9i3yxGq+ecwqhoNO47BJ7xfQcGlhhOsqN9O7eP92qE6AOnkqP+v4= X-Received: by 2002:a92:b6c3:: with SMTP id m64mr15859393ill.23.1607421095680; Tue, 08 Dec 2020 01:51:35 -0800 (PST) MIME-Version: 1.0 References: <20201119153901.53705-1-steven.price@arm.com> <20201119184248.4bycy6ouvaxqdiiy@kamzik.brq.redhat.com> <46fd98a2-ee39-0086-9159-b38c406935ab@arm.com> In-Reply-To: <46fd98a2-ee39-0086-9159-b38c406935ab@arm.com> From: Haibo Xu Date: Tue, 8 Dec 2020 17:51:24 +0800 Message-ID: Subject: Re: [PATCH v5 0/2] MTE support for KVM guest To: Steven Price Cc: lkml - Kernel Mailing List , Juan Quintela , Marc Zyngier , Richard Henderson , QEMU Developers , "Dr. David Alan Gilbert" , Catalin Marinas , Thomas Gleixner , Will Deacon , kvmarm , arm-mail-list , Dave Martin 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 Mon, 7 Dec 2020 at 22:48, Steven Price wrote: > > On 04/12/2020 08:25, Haibo Xu wrote: > > On Fri, 20 Nov 2020 at 17:51, Steven Price wrote: > >> > >> On 19/11/2020 19:11, Marc Zyngier wrote: > >>> On 2020-11-19 18:42, Andrew Jones wrote: > >>>> On Thu, Nov 19, 2020 at 03:45:40PM +0000, Peter Maydell wrote: > >>>>> On Thu, 19 Nov 2020 at 15:39, Steven Price wrote: > >>>>>> This series adds support for Arm's Memory Tagging Extension (MTE) to > >>>>>> KVM, allowing KVM guests to make use of it. This builds on the > >>>>> existing > >>>>>> user space support already in v5.10-rc1, see [1] for an overview. > >>>>> > >>>>>> The change to require the VMM to map all guest memory PROT_MTE is > >>>>>> significant as it means that the VMM has to deal with the MTE tags > >>>>> even > >>>>>> if it doesn't care about them (e.g. for virtual devices or if the VMM > >>>>>> doesn't support migration). Also unfortunately because the VMM can > >>>>>> change the memory layout at any time the check for PROT_MTE/VM_MTE has > >>>>>> to be done very late (at the point of faulting pages into stage 2). > >>>>> > >>>>> I'm a bit dubious about requring the VMM to map the guest memory > >>>>> PROT_MTE unless somebody's done at least a sketch of the design > >>>>> for how this would work on the QEMU side. Currently QEMU just > >>>>> assumes the guest memory is guest memory and it can access it > >>>>> without special precautions... > >>>>> > >>>> > >>>> There are two statements being made here: > >>>> > >>>> 1) Requiring the use of PROT_MTE when mapping guest memory may not fit > >>>> QEMU well. > >>>> > >>>> 2) New KVM features should be accompanied with supporting QEMU code in > >>>> order to prove that the APIs make sense. > >>>> > >>>> I strongly agree with (2). While kvmtool supports some quick testing, it > >>>> doesn't support migration. We must test all new features with a migration > >>>> supporting VMM. > >>>> > >>>> I'm not sure about (1). I don't feel like it should be a major problem, > >>>> but (2). > >> > >> (1) seems to be contentious whichever way we go. Either PROT_MTE isn't > >> required in which case it's easy to accidentally screw up migration, or > >> it is required in which case it's difficult to handle normal guest > >> memory from the VMM. I get the impression that probably I should go back > >> to the previous approach - sorry for the distraction with this change. > >> > >> (2) isn't something I'm trying to skip, but I'm limited in what I can do > >> myself so would appreciate help here. Haibo is looking into this. > >> > > > > Hi Steven, > > > > Sorry for the later reply! > > > > I have finished the POC for the MTE migration support with the assumption > > that all the memory is mapped with PROT_MTE. But I got stuck in the test > > with a FVP setup. Previously, I successfully compiled a test case to verify > > the basic function of MTE in a guest. But these days, the re-compiled test > > can't be executed by the guest(very weird). The short plan to verify > > the migration > > is to set the MTE tags on one page in the guest, and try to dump the migrated > > memory contents. > > Hi Haibo, > > Sounds like you are making good progress - thanks for the update. Have > you thought about how the PROT_MTE mappings might work if QEMU itself > were to use MTE? My worry is that we end up with MTE in a guest > preventing QEMU from using MTE itself (because of the PROT_MTE > mappings). I'm hoping QEMU can wrap its use of guest memory in a > sequence which disables tag checking (something similar will be needed > for the "protected VM" use case anyway), but this isn't something I've > looked into. As far as I can see, to map all the guest memory with PROT_MTE in VMM is a little weird, and lots of APIs have to be changed to include this flag. IMHO, it would be better if the KVM can provide new APIs to load/store the guest memory tag which may make it easier to enable the Qemu migration support. > > > I will update the status later next week! > > Great, I look forward to hearing how it goes. > > Thanks, > > Steve _______________________________________________ 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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 10AC5C4361B for ; Tue, 8 Dec 2020 09:52:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 A5D9C23A82 for ; Tue, 8 Dec 2020 09:52:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5D9C23A82 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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=NyW5fh4Cbmv8K+Zyem0ZiBvqJQo595TngrnsX6plqm0=; b=Y3qNSsGsfW0919tofIszEdRaI +Xh9nrRYaUCH1lkZ6KnHOpuIXAD0lUQtRxm9umN09FPsCHiLv9/oGOcqP6gV8dac+y5iZ5dygcR1a g01RYJeP9M8Gu4+g9bhGSIUFM20wBEqldnmcWM22ctD+lssTJSdhZDlPQxyc0xAwzBuyQoxO8r+ul Ckk4/vE8cm1QluiJmLg5K9JOP5BtlX8+j9uNoNYjm6MBBNjhDyIhxafegppT0HNYYR5fzjc/jZ216 xtJFlJ8pZZvaKS/Nlma34xaSqTKrOUB8EptLw/TBQtL/mRdgw9VITOR/ijVwi/iVgE+AFhYZANsiO MxfMr6Pqg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmZer-0004AJ-6p; Tue, 08 Dec 2020 09:51:45 +0000 Received: from mail-il1-x143.google.com ([2607:f8b0:4864:20::143]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmZel-00048d-Eu for linux-arm-kernel@lists.infradead.org; Tue, 08 Dec 2020 09:51:40 +0000 Received: by mail-il1-x143.google.com with SMTP id v3so15009390ilo.5 for ; Tue, 08 Dec 2020 01:51:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lICLkvZe3ToayMLnSKCmLUo/K0jAtkBksOUim1ibfBY=; b=VN5ue7ud1agT4R98hMSjewuu2LrhcoCORuoWMvUQhM7WIE3bjCyU1RI+UgBzBQJvSa DeJL9Vj1lqwp73sDe7qAZCQGzPaV38h3Ak992sNOyFdK9N7Dm3uDnwV9u6kk0wf5oLPB uO9PIK/I6Z6GNd0ccNasHlSEBZ2nO8mOiEDhptmjoIfoInncgQvQccrrwtJUCDzYB30P Cy88O7m1MgujhOWND/z3r645zM41SRjSULqc4yb+GHroCLcQnzvhXbpI+hCbEMx3n4TS sc2KpyZHMAx+YZQUcK9AZRa23RmwmxNGJ+uTYKUKf5/xrlbqSZ0h5j00nmz/ND5XE8Ei fmsA== 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=lICLkvZe3ToayMLnSKCmLUo/K0jAtkBksOUim1ibfBY=; b=moQrtx2Bci5VFK/h+9qZ9O6EIYIJHpPTKTSAcwbNF0oBhIi3GWW6kawiAGKJ75tM9V WC133/pY0tRX212Vp/gwILBH+0mRklMR5ZwXBTPqIWTW5BUM7y1czI0ZFICVy2UOaITh +eXtZtLLl5IEDDpD2DRS131eZUHbqAIJOIpUjUaHSQP3SvDJV0nc+BpgamL67nPCjxab Ypdtre04WYRrR5KW4DBV5sLmRsYUjWXycirWwRtv5q8/lN9Tg0kZoKd2024q/d3oZlye wclCMd/vjvXprLceQV+vS21vK3EgVC6c7gqQ9VQRadMGMFO4SfOtv8QnERvIR8ReuxiD fi2Q== X-Gm-Message-State: AOAM531V534lAN22cDRzKj9OX1GGJnGnNu1tjXnlkDGWEvAPuM5Z483z cJqncXWvkWtjFVOmPidBZ/YUK0lEZll3TsQsUpiw X-Google-Smtp-Source: ABdhPJwGCf1kaRkx/7nAHZDQ/wyyZFTaySkgpZz9i3yxGq+ecwqhoNO47BJ7xfQcGlhhOsqN9O7eP92qE6AOnkqP+v4= X-Received: by 2002:a92:b6c3:: with SMTP id m64mr15859393ill.23.1607421095680; Tue, 08 Dec 2020 01:51:35 -0800 (PST) MIME-Version: 1.0 References: <20201119153901.53705-1-steven.price@arm.com> <20201119184248.4bycy6ouvaxqdiiy@kamzik.brq.redhat.com> <46fd98a2-ee39-0086-9159-b38c406935ab@arm.com> In-Reply-To: <46fd98a2-ee39-0086-9159-b38c406935ab@arm.com> From: Haibo Xu Date: Tue, 8 Dec 2020 17:51:24 +0800 Message-ID: Subject: Re: [PATCH v5 0/2] MTE support for KVM guest To: Steven Price X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201208_045139_575461_DC9509F8 X-CRM114-Status: GOOD ( 38.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jones , lkml - Kernel Mailing List , Juan Quintela , Marc Zyngier , Richard Henderson , QEMU Developers , "Dr. David Alan Gilbert" , Catalin Marinas , Thomas Gleixner , Will Deacon , kvmarm , arm-mail-list , Dave Martin 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 Mon, 7 Dec 2020 at 22:48, Steven Price wrote: > > On 04/12/2020 08:25, Haibo Xu wrote: > > On Fri, 20 Nov 2020 at 17:51, Steven Price wrote: > >> > >> On 19/11/2020 19:11, Marc Zyngier wrote: > >>> On 2020-11-19 18:42, Andrew Jones wrote: > >>>> On Thu, Nov 19, 2020 at 03:45:40PM +0000, Peter Maydell wrote: > >>>>> On Thu, 19 Nov 2020 at 15:39, Steven Price wrote: > >>>>>> This series adds support for Arm's Memory Tagging Extension (MTE) to > >>>>>> KVM, allowing KVM guests to make use of it. This builds on the > >>>>> existing > >>>>>> user space support already in v5.10-rc1, see [1] for an overview. > >>>>> > >>>>>> The change to require the VMM to map all guest memory PROT_MTE is > >>>>>> significant as it means that the VMM has to deal with the MTE tags > >>>>> even > >>>>>> if it doesn't care about them (e.g. for virtual devices or if the VMM > >>>>>> doesn't support migration). Also unfortunately because the VMM can > >>>>>> change the memory layout at any time the check for PROT_MTE/VM_MTE has > >>>>>> to be done very late (at the point of faulting pages into stage 2). > >>>>> > >>>>> I'm a bit dubious about requring the VMM to map the guest memory > >>>>> PROT_MTE unless somebody's done at least a sketch of the design > >>>>> for how this would work on the QEMU side. Currently QEMU just > >>>>> assumes the guest memory is guest memory and it can access it > >>>>> without special precautions... > >>>>> > >>>> > >>>> There are two statements being made here: > >>>> > >>>> 1) Requiring the use of PROT_MTE when mapping guest memory may not fit > >>>> QEMU well. > >>>> > >>>> 2) New KVM features should be accompanied with supporting QEMU code in > >>>> order to prove that the APIs make sense. > >>>> > >>>> I strongly agree with (2). While kvmtool supports some quick testing, it > >>>> doesn't support migration. We must test all new features with a migration > >>>> supporting VMM. > >>>> > >>>> I'm not sure about (1). I don't feel like it should be a major problem, > >>>> but (2). > >> > >> (1) seems to be contentious whichever way we go. Either PROT_MTE isn't > >> required in which case it's easy to accidentally screw up migration, or > >> it is required in which case it's difficult to handle normal guest > >> memory from the VMM. I get the impression that probably I should go back > >> to the previous approach - sorry for the distraction with this change. > >> > >> (2) isn't something I'm trying to skip, but I'm limited in what I can do > >> myself so would appreciate help here. Haibo is looking into this. > >> > > > > Hi Steven, > > > > Sorry for the later reply! > > > > I have finished the POC for the MTE migration support with the assumption > > that all the memory is mapped with PROT_MTE. But I got stuck in the test > > with a FVP setup. Previously, I successfully compiled a test case to verify > > the basic function of MTE in a guest. But these days, the re-compiled test > > can't be executed by the guest(very weird). The short plan to verify > > the migration > > is to set the MTE tags on one page in the guest, and try to dump the migrated > > memory contents. > > Hi Haibo, > > Sounds like you are making good progress - thanks for the update. Have > you thought about how the PROT_MTE mappings might work if QEMU itself > were to use MTE? My worry is that we end up with MTE in a guest > preventing QEMU from using MTE itself (because of the PROT_MTE > mappings). I'm hoping QEMU can wrap its use of guest memory in a > sequence which disables tag checking (something similar will be needed > for the "protected VM" use case anyway), but this isn't something I've > looked into. As far as I can see, to map all the guest memory with PROT_MTE in VMM is a little weird, and lots of APIs have to be changed to include this flag. IMHO, it would be better if the KVM can provide new APIs to load/store the guest memory tag which may make it easier to enable the Qemu migration support. > > > I will update the status later next week! > > Great, I look forward to hearing how it goes. > > Thanks, > > Steve _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel