Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp482989ybt; Wed, 24 Jun 2020 04:11:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTDyPr3hM31Mn/zc4auQwYighcneqib0/gYXkibjoenVqyqXHT/dbeWxZqqffu70D1ak/s X-Received: by 2002:a17:906:76c4:: with SMTP id q4mr25914122ejn.371.1592997085719; Wed, 24 Jun 2020 04:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592997085; cv=none; d=google.com; s=arc-20160816; b=wCpMeuMG3Z0POcw+YJnBpD0KnyLxP1Y173pE4UCHJU3cdqOXx3/kcao9SrxecbkRyg ozZyXglFNs7SGTr5/9vzt0E9flciEMb583ilz/bFv7hilA0cqZ55qm0DwMeCKZVHOIDZ fKjzSsiMhvi8NSTZUGnbVvQ1DGDgS/9d+DZvj4Kxbs5A3J2o1RyEu19KGrmfrZfISuy1 6TZLt/G1u2+s2xRJdFZ20NsRyU6prsUQSxorXNaJ9bX60NZcj9nqX3O7uL+WcAOULy76 eTmgKP1ofC6EA39DhN3Q3oxrw3COGTb67JIAFe0g71icYXwv9xFb+BPSIINBdGmvlGvy A2aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=R6VMkKubJD5uXmuj98bhlRPUBSIX4bLsoqhBEBLAY0g=; b=CCZFFW7Nog6IHF/2CWBsGo07DTj8OOwLyh5aciun8y6MBtaUUBzZ2UipEfCHq/QIQP HfIE6ACF/8PHtUzJvmSakXB6+Te8Uk9NARZlRrcQT07r6pRNQB7WX2iWp6fRbzNfKryt z+V28INjoo06z5fY/YuG6fQcyA2gZG/1H/GAUJTwDFKhTK6isbv1KJN6MW3cWKFiA1w3 WsRoQPlujT2yhclPtx9+Xln4Dx8U5UbwT3BU+hDztJA8cYNku7sl3mazzoRkviAwlHcG B2EE1iV+xMxYerx1T/2FpmUZY4cgX3fRByKrRy7hErAAI0MOPX/k5aJw/icMLwB3Fr7S mpYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e24si7483500ejd.406.2020.06.24.04.11.01; Wed, 24 Jun 2020 04:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390426AbgFXLJq (ORCPT + 99 others); Wed, 24 Jun 2020 07:09:46 -0400 Received: from foss.arm.com ([217.140.110.172]:35088 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728656AbgFXLJp (ORCPT ); Wed, 24 Jun 2020 07:09:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 127161F1; Wed, 24 Jun 2020 04:09:45 -0700 (PDT) Received: from gaia (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BFCF53F6CF; Wed, 24 Jun 2020 04:09:43 -0700 (PDT) Date: Wed, 24 Jun 2020 12:09:33 +0100 From: Catalin Marinas To: Steven Price Cc: Dave Martin , Peter Maydell , Marc Zyngier , lkml - Kernel Mailing List , "kvmarm@lists.cs.columbia.edu" , Thomas Gleixner , Will Deacon , arm-mail-list Subject: Re: [RFC PATCH 0/2] MTE support for KVM guest Message-ID: <20200624110904.GB11863@gaia> References: <20200617123844.29960-1-steven.price@arm.com> <20200624093846.GA11863@gaia> <20200624103412.GD25945@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 24, 2020 at 12:03:35PM +0100, Steven Price wrote: > On 24/06/2020 11:34, Dave Martin wrote: > > On Wed, Jun 24, 2020 at 10:38:48AM +0100, Catalin Marinas wrote: > > > On Tue, Jun 23, 2020 at 07:05:07PM +0100, Peter Maydell wrote: > > > > On Wed, 17 Jun 2020 at 13:39, Steven Price wrote: > > > > > These patches add support to KVM to enable MTE within a guest. It is > > > > > based on Catalin's v4 MTE user space series[1]. > > > > > > > > > > [1] http://lkml.kernel.org/r/20200515171612.1020-1-catalin.marinas%40arm.com > > > > > > > > > > Posting as an RFC as I'd like feedback on the approach taken. > > > > > > > > What's your plan for handling tags across VM migration? > > > > Will the kernel expose the tag ram to userspace so we > > > > can copy it from the source machine to the destination > > > > at the same time as we copy the actual ram contents ? > > > > > > Qemu can map the guest memory with PROT_MTE and access the tags directly > > > with LDG/STG instructions. Steven was actually asking in the cover > > > letter whether we should require that the VMM maps the guest memory with > > > PROT_MTE as a guarantee that it can access the guest tags. > > > > > > There is no architecturally visible tag ram (tag storage), that's a > > > microarchitecture detail. > > > > If userspace maps the guest memory with PROT_MTE for dump purposes, > > isn't it going to get tag check faults when accessing the memory > > (i.e., when dumping the regular memory content, not the tags > > specifically). > > > > Does it need to map two aliases, one with PROT_MTE and one without, > > and is that architecturally valid? > > Userspace would either need to have two mappings (I don't believe there are > any architectural issues with that - but this could be awkward to arrange in > some situations) or be careful to avoid faults. Basically your choices with > one mapping are: > > 1. Disable tag checking (using prctl) when touching the memory. This works > but means you lose tag checking for the VMM's own accesses during this code > sequence. > > 2. Read the tag values and ensure you use the correct tag. This suffers > from race conditions if the VM is still running. > > 3. Use one of the exceptions in the architecture that generates a Tag > Unchecked access. Sadly the only remotely useful thing I can see in the v8 > ARM is "A base register plus immediate offset addressing form, with the SP > as the base register." - but making sure SP is in range of where you want to > access would be a pain. Or: 4. Set PSTATE.TCO when accessing tagged memory in an unsafe way. -- Catalin