Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp454234pxb; Fri, 8 Jan 2021 09:06:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQytSFb6yu7FUkieWzoDdZvKiIDbyPaTuyerZcd4fUK/2ljtIgTLX8boDM6ErDMVxcpOVD X-Received: by 2002:a50:b944:: with SMTP id m62mr5892626ede.182.1610125601506; Fri, 08 Jan 2021 09:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610125601; cv=none; d=google.com; s=arc-20160816; b=LGo7PHcdplZVvS2cV2HUYnJ4q2nwBc1NZamXGom/g0xf2rZxvnnibXkgSInY4m5A1m PI09tc1uvEigsCo6B/R5rnZgL/Te6LnUjNc4jGN4pSXnNyCgX6JL5FnJG7Acw2CEAwSF ofy9rlGzdxfwAye7YhHpJjtCJ7tCxhfLehAM0UEaj+AkLAufJPkZRWU3YKtRJZ4KTmA0 Cu6Fs7wzY8UpPybMTLvwICA63iRydaTFqYjeqtQUSc3heI+ATLhljKqBNiWw+Gy/y/Bl yzZxndtlWwynNSqavpV5zUMfcZkOWbdruPNc0eW1b+aDp3ygd4CV4cRMRKfskcMDW7Mm iO8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=s5NRNeTFubW7Kt4473nSQsOCVbRZZZxYs/Q1kP00Txs=; b=HE7aJ4ui0YLe5fy6+T33U2yviibUlyfUTiLx349qjaHM+sJI1KPPkR+qbMOyQVAZ4s WjQHt3BDmo+eTPPYN4zXkTJsZDTL2uX/4lnrMz2P3cQWLpoILzwvtcmx/fRNz1zIrgFH f3VX6Vl4MffVnm3x3NhL9NcT01kN4nMwT3uPnF2E3jwN4lm+xovERYGOB5pXrm0Az3zQ 5/vjje+XzQ7lNW8HE+NmRbaidW5GVQs6IKAW0+G1x4hzfwLd8wpSKqt657xcc2LWKNwd 9HWoLblnh6uF63lWgHYMj5e+cyc+48wLUUyzGOkKvl942iGDiJFoI+xUABxlrgSD3fPZ tpmQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si3888849eds.57.2021.01.08.09.06.13; Fri, 08 Jan 2021 09:06:41 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728092AbhAHREl (ORCPT + 99 others); Fri, 8 Jan 2021 12:04:41 -0500 Received: from foss.arm.com ([217.140.110.172]:54258 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726935AbhAHREl (ORCPT ); Fri, 8 Jan 2021 12:04:41 -0500 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 1B35E11FB; Fri, 8 Jan 2021 09:03:56 -0800 (PST) Received: from [192.168.1.179] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 034A43F70D; Fri, 8 Jan 2021 09:03:53 -0800 (PST) Subject: Re: [PATCH] KVM: arm64: Compute TPIDR_EL2 ignoring MTE tag To: Marc Zyngier Cc: Catalin Marinas , Will Deacon , James Morse , Julien Thierry , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Alexander Potapenko , Andrew Morton , Andrey Konovalov , Vincenzo Frascino References: <20210108161254.53674-1-steven.price@arm.com> From: Steven Price Message-ID: Date: Fri, 8 Jan 2021 17:03:52 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/01/2021 16:51, Marc Zyngier wrote: > Hi Steven, > > On 2021-01-08 16:12, Steven Price wrote: >> KASAN in HW_TAGS mode will store MTE tags in the top byte of the >> pointer. When computing the offset for TPIDR_EL2 we don't want anything >> in the top byte, so remove the tag to ensure the computation is correct >> no matter what the tag. >> >> Fixes: 94ab5b61ee16 ("kasan, arm64: enable CONFIG_KASAN_HW_TAGS") >> Signed-off-by: Steven Price >> --- >> Without this fix I can't boot a config with KASAN_HW_TAGS and KVM on an >> MTE enabled host. I'm unsure if this should really be in >> this_cpu_ptr_nvhe_sym(). > > this_cpu_ptr_nvhe_sym() should return something that is valid for > the EL1 kernel, so I guess untagging in the helper may not be > that useful. Makes sense and was my suspicion. > However, I'm more concerned by anything at requires us to follow > pointers set up by EL1 at EL2. It looks to me that the only reason > the whole thing works is because kern_hyp_va() *accidentally* drops > tags before applying the EL1/EL2 offset... In the case I'm fixing this is intended to be an offset calculation - it's just messed up by the presence of an MTE tag in one of the pointers. I agree I was somewhat surprised when everything 'just worked' with this one change - and I think you're right it's because kern_hyp_va() 'just happens' to lose the tags. Of course there may be other bugs lurking - running MTE+KASAN on the model is slow so I didn't do much beyond boot it. One of the 'fun' things about MTE is that you can no longer do pointer subtraction to calculate the offset unless the pointers are actually from the same allocation (and therefore have the same tag). I'm sure the C language experts would point out that's "always been the case" but it will probably break things elsewhere too. Steve > Or am I getting it wrong? > > Thanks, > >         M.