Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp717949pxb; Tue, 2 Feb 2021 16:34:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwy6O/4HAgodWgYC8ohWyQVGOOC5e8ghYWC58vZgzyWvramO69bmLfrKGCOfwmnKU//RpVv X-Received: by 2002:a17:906:660b:: with SMTP id b11mr604587ejp.458.1612312445848; Tue, 02 Feb 2021 16:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612312445; cv=none; d=google.com; s=arc-20160816; b=m9vA7lN9woh3ftMMFpM2SaaIJ7/4wQjxfoT3kgN/iPk2v9oyoUmNvU+G3KJygN7xHH QBspofUfPdJTeSPfZIYzl5C9MX1iJZI8NjqWl3OgOg8nm0J3uh/WQD6/aapdA6yP4Em2 coh1XGZRGkVvkVDOxQ6IkczOtw9HlyoSc31q0VJWJu4VTmmBIjHMmt9EwgZ8hVjAqe73 w5L5GzSGpTBkhZVvjdo3J4fo3bWXi/Sh0SG19t9/v9NvOElg95D1eU4vvyejotqxQmxU 38wsMovADsDXin6xRHOZgtFwvck4u2Eo+q8iBvqU3vqmuusLK1rW4yzJrAHAEK5fnBmp MDrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bkJ396ovGQTUsRhCdFoZILK6dCLPexHJ2EGZdWor+hw=; b=Gl9erpOamA8fxX2vgS2VbVyDte7ktNbBh/MvfJZJlTNGggeBpQbnO8o+UnK8CuU0dl k27TY3kyfrxUSEoobnda+dXOUMkos0zb0nh19t/lvabO4FwlPpmAAqLO0oi4xZTIP46f vKkOiA2/n7tGgfwvsyXr6ykaRjt2KrVAy8sbcYy+jvlthD+CfDjEYzawFXlFsPKwU+Cr zIQhJ0MlahsIACKWbcaxp/sl+DWqJO4PQ7rNLT3VzTX1dTF3YjHUVZ71Pcz4ohXSW5d8 k04a7VyILsqeEo5PLDTVSZjsFJaWJUS/xatV59FrXdLunrwJgEiSUU6Q/EDCzvsCFgyC S4Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bmHbrW4w; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ho43si270611ejc.421.2021.02.02.16.33.18; Tue, 02 Feb 2021 16:34:05 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=bmHbrW4w; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238299AbhBBSHp (ORCPT + 99 others); Tue, 2 Feb 2021 13:07:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238015AbhBBSFb (ORCPT ); Tue, 2 Feb 2021 13:05:31 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9F40C06174A for ; Tue, 2 Feb 2021 10:04:50 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id e9so2905779pjj.0 for ; Tue, 02 Feb 2021 10:04:50 -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=bkJ396ovGQTUsRhCdFoZILK6dCLPexHJ2EGZdWor+hw=; b=bmHbrW4wHvIdfjHfeZ3EaQjyVR5RRbKrvsyfN94JInNi9Cn/Ji526G1EpUl55uf6bH m13PPwd6OvYcUlrgA/4HEDMO743f3REGWb/rhRNZx0Aufi7rf6VXi+aZ5OuZiITpO1L9 7lT7EPS+7AOGkhtIhtsHxq98UcXFLblKenrLQqqrlr1B45IRYPlDXDDJTwOVMJa/BGKP yBbfOe7hVFgzgcoQsCfXkRDgtuvOBds9FsxJP+7V6ungIy4DVbkpiRQsI3TRPgliGdW1 DaaAKLFjlCfHCv7Q4+Qh5yw17ptKBNaw6Pl8Q50l3Y1UPSOqxUiL72dpSLziTfMOEIlk 6U5Q== 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=bkJ396ovGQTUsRhCdFoZILK6dCLPexHJ2EGZdWor+hw=; b=D60wiNEaQHL7en/rJnKgouwXHxuUCFYBTilfrniXKaGPwNaUbmhH3V4j+c18YDh+aB 3hVBTloNRwvx9t7d6KYWnrq5r9IHRnrM1tSojsRWW36eQ30WTiV2XJ4QL2cC3F75bJoD 7MnrqXAtrVPH68Mcox1wc5blVk2dL+BagTjCvqLzJ9BTKJYYpuu9uWuEyECOnz8Daj78 EIPbYl9q01Z0OnZu0DYiD+0VE9GSpT7zigjyglHBzfA4fXJBbgqJPlZqS9J1Ww3s4Bzt 60QlO7bbBS1d539Tx3oXHIlegWSsKpYM/F9wEDgFCnKKd8HEFqYTSswSBuZuF7heP3SJ +ZPA== X-Gm-Message-State: AOAM531Hs2jYR9P3Sj+5XKaHm5D2yTX8Kz3jbe3ytOlmizcBzyNLjsJG FTTpD5rW+1EigLyj9vf7JFSobAlPxOJft8y1VlfBew== X-Received: by 2002:a17:90b:30d4:: with SMTP id hi20mr5325944pjb.41.1612289090058; Tue, 02 Feb 2021 10:04:50 -0800 (PST) MIME-Version: 1.0 References: <17d6bef698d193f5fe0d8baee0e232a351e23a32.1612208222.git.andreyknvl@google.com> <20210202154200.GC26895@gaia> In-Reply-To: <20210202154200.GC26895@gaia> From: Andrey Konovalov Date: Tue, 2 Feb 2021 19:04:38 +0100 Message-ID: Subject: Re: [PATCH 10/12] arm64: kasan: simplify and inline MTE functions To: Catalin Marinas Cc: Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver , Andrew Morton , Will Deacon , Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev , Linux ARM , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 2, 2021 at 4:42 PM Catalin Marinas wrote: > > On Mon, Feb 01, 2021 at 08:43:34PM +0100, Andrey Konovalov wrote: > > +/* > > + * Assign allocation tags for a region of memory based on the pointer tag. > > + * Note: The address must be non-NULL and MTE_GRANULE_SIZE aligned and > > + * size must be non-zero and MTE_GRANULE_SIZE aligned. > > + */ > > OK, so we rely on the caller to sanity-check the range. Fine by me but I > can see (un)poison_range() only doing this for the size. Do we guarantee > that the start address is aligned? See the previous patch in the series. kasan_poison() checks and warns on both unaligned addr and size. kasan_unpoison() checks addr and rounds up size. > > +static __always_inline void mte_set_mem_tag_range(void *addr, size_t size, u8 tag) > > +{ > > + u64 curr, end; > > + > > + if (!size) > > + return; > > + > > + curr = (u64)__tag_set(addr, tag); > > + end = curr + size; > > + > > + do { > > + /* > > + * 'asm volatile' is required to prevent the compiler to move > > + * the statement outside of the loop. > > + */ > > + asm volatile(__MTE_PREAMBLE "stg %0, [%0]" > > + : > > + : "r" (curr) > > + : "memory"); > > + > > + curr += MTE_GRANULE_SIZE; > > + } while (curr != end); > > +} > > > > void mte_enable_kernel_sync(void); > > void mte_enable_kernel_async(void); > > @@ -47,10 +95,12 @@ static inline u8 mte_get_mem_tag(void *addr) > > { > > return 0xFF; > > } > > + > > static inline u8 mte_get_random_tag(void) > > { > > return 0xFF; > > } > > + > > static inline void *mte_set_mem_tag_range(void *addr, size_t size, u8 tag) > > This function used to return a pointer and that's what the dummy static > inline does here. However, the new mte_set_mem_tag_range() doesn't > return anything. We should have consistency between the two (the new > static void definition is fine by me). Right, forgot to update the empty function definition. Will do in v2. > > Otherwise the patch looks fine. > > Reviewed-by: Catalin Marinas Thanks!