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=-14.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,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL 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 9232FC55179 for ; Thu, 5 Nov 2020 18:10:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DAE752087D for ; Thu, 5 Nov 2020 18:10:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="F491/pGR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DAE752087D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2B19C6B0178; Thu, 5 Nov 2020 13:10:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 23BB16B017A; Thu, 5 Nov 2020 13:10:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 129F36B017B; Thu, 5 Nov 2020 13:10:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id D54176B0178 for ; Thu, 5 Nov 2020 13:10:11 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 75D37824999B for ; Thu, 5 Nov 2020 18:10:11 +0000 (UTC) X-FDA: 77451153822.08.thing88_0f17680272cb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 4C9CA1819E766 for ; Thu, 5 Nov 2020 18:10:11 +0000 (UTC) X-HE-Tag: thing88_0f17680272cb X-Filterd-Recvd-Size: 5297 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 18:10:10 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id c20so1950564pfr.8 for ; Thu, 05 Nov 2020 10:10:10 -0800 (PST) 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=mAoNSuBVW5u3fxEUjvf+bvrAfgyMkB897WinOBxVK3w=; b=F491/pGRojhINVVl3SszqGp2vZ+2u+JaPtTLKZpnytAPIGHN/++hTHce0DgSA66RxC aHMtp+v9EwdtmbCsNx5pZiltbcEs9KypJZ1rPA7LBmeRLf2rju7EczSN+t/Za0q01u05 3GrwR4M6Dqd1fvAFcP+4amce+O8iOsacSW0S6s2eas3UiRxwmxsP66O22mOX2/boDOO7 PRZMpe/qyzdiQp0PbQjs5sKBDMTnjO72t603qUbo5GKOT9VYrLY7b8RaHasOMdMzzEcy KQuThEPWKpm7wID3Kry+1Xigzj2UAY8DKFCokZ/bqXJT6hbyBV15tcYApupqAYsrgZAs 5vSw== 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=mAoNSuBVW5u3fxEUjvf+bvrAfgyMkB897WinOBxVK3w=; b=d/rZInA08E9Rc+Pas6T8293DV62/7AHkzQ+ubX5ujCw4OyGYvJ8Wn4K6DdD1WqWMGU tZPScQv9q+QgTVE12P2HdWHAR4LAHxk5vJOviybvJy5qyJj6lHorN2kwfq9zVQg+vPRs D3b//uPPCedSMIYwTJvfzF4cV+0Jn2+9xC1T2wucm9P+TMTCYDjlSq0+0WfRbncBABPs SjEWYUDtj28feo0CieToN4CPtHD/+0AGssiOBFZct191kZGWYv8dtVsgCHN2yMg+smag XyQ+AnNLu0KnQRLpO9SrAsEHOiRAN8IvS6qm85zbMjWA6sNSpuhbYQO7J5Ci6RaElbSa GWJg== X-Gm-Message-State: AOAM532gZpaoru/tL+aJBdPlYYiCEkowHVQ4WWtDRRyVMm1RwKBV6SDw hCJdiyxnx/xWT9Qez8fU1MJ4+DvIQm+1DSxA3YTisw== X-Google-Smtp-Source: ABdhPJyhqZ00u0pP8D204fPo/eIgdONzEkL+r5w1dxzrQid0f/YcXOppsgFmFTvjin+GdKBUrQmEfPzexsRxbDIR9hA= X-Received: by 2002:a05:6a00:16c4:b029:162:bf9f:6458 with SMTP id l4-20020a056a0016c4b0290162bf9f6458mr3576815pfc.55.1604599809690; Thu, 05 Nov 2020 10:10:09 -0800 (PST) MIME-Version: 1.0 References: <5e3c76cac4b161fe39e3fc8ace614400bc2fb5b1.1604531793.git.andreyknvl@google.com> <20201105172549.GE30030@gaia> <20201105173901.GH30030@gaia> In-Reply-To: <20201105173901.GH30030@gaia> From: Andrey Konovalov Date: Thu, 5 Nov 2020 19:09:58 +0100 Message-ID: Subject: Re: [PATCH v8 30/43] arm64: kasan: Allow enabling in-kernel MTE To: Catalin Marinas Cc: Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev , Linux ARM , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Nov 5, 2020 at 6:39 PM Catalin Marinas wrote: > > On Thu, Nov 05, 2020 at 06:29:17PM +0100, Andrey Konovalov wrote: > > On Thu, Nov 5, 2020 at 6:26 PM Catalin Marinas wrote: > > > > > > On Thu, Nov 05, 2020 at 12:18:45AM +0100, Andrey Konovalov wrote: > > > > diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c > > > > index 06ba6c923ab7..fcfbefcc3174 100644 > > > > --- a/arch/arm64/kernel/mte.c > > > > +++ b/arch/arm64/kernel/mte.c > > > > @@ -121,6 +121,13 @@ void *mte_set_mem_tag_range(void *addr, size_t size, u8 tag) > > > > return ptr; > > > > } > > > > > > > > +void __init mte_init_tags(u64 max_tag) > > > > +{ > > > > + /* Enable MTE Sync Mode for EL1. */ > > > > + sysreg_clear_set(sctlr_el1, SCTLR_ELx_TCF_MASK, SCTLR_ELx_TCF_SYNC); > > > > + isb(); > > > > +} > > > > > > Is this going to be called on each CPU? I quickly went through the rest > > > of the patches and couldn't see how. > > > > Yes, on each CPU. This is done via kasan_init_hw_tags() that is called > > from cpu_enable_mte(). This change is added in the "kasan, arm64: > > implement HW_TAGS runtime". > > Ah, I got there eventually in patch 38. Too many indirections ;) (I'm > sure we could have trimmed them down a bit, hw_init_tags == > arch_init_tags == mte_init_tags). The idea with these indirections was to make hw_tags.c to not directly call MTE stuff and abstract away the underlying memory tagging implementation. We won't know for sure how fitting these abstractions are before we add another memory tagging implementation though :) > > Would it make sense to put it into a separate patch? > > I think that's fine. I had the impression that kasan_init_hw_tags() > should only be called once. This was the case before, but not anymore. I've also added a comment before the kasan_init_hw_tags() definition.