Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp372168pxu; Wed, 25 Nov 2020 05:30:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqL8NS4SFv/yzbxy5OJH9WhCWjZKl00Oqc/Zmi2Q3bCDFLcRwtILk1HxhvrKQ+CQmu+wIn X-Received: by 2002:a17:906:b783:: with SMTP id dt3mr3170908ejb.534.1606311029654; Wed, 25 Nov 2020 05:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606311029; cv=none; d=google.com; s=arc-20160816; b=pwMU14Ubx3iWhFYi7dOH7gUL4/zzB+o1rb5cZcrR6N1ZzmB8lDeGI/632+5nWnTjPt Nsgl3p+jq8aSm5kF8+JV72HHNH2U7fOWqGUcUafp6muo+s9E+h422LJHSb+60RSpOkGX zcKiqN206U6lnApqLtBUUwE92NjuYgW6KYj34Y+Kz0gMrhm0U1iDxGDXRF6UGrcVNb0H 4hSE4xgZmdF8p8WkZ+tOfK7YDw4e0PHLa9TZz21LjGrJsJyWV388IzZKFJ1X3aFWuE0n WeXAevhMZjIiazT54YAeNDNrdRu8JeAYXNQ1JG6nGNwiVOHNd6ANka4N1uzlmOCHBlJ+ euFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AlYFyy65mMJrzPAF8ZbtQbw2MzAGfUKKDzhurYImYTg=; b=pAO7hMvxWM1WKf4ub1q9rDcE98Jqx8toJyOPeItyYL+tKwyjckKrw8kUPByodp21zl nTWhkHI6ijnxI7U294MECvJHd9HJpEIHcy3XIzmKKgXKF2w0w2mV7oU/OVuOBp5gwxkL CF4/lfxsyN/Bba9cNuR8z1zCAu8vCP0dwUEr+jzoEjoG/XmkrLZ/4SmnLsUb5lLV9ZJi lcsu62QmV3Q/Hm/f95JK7qAE0siD/HW6V9bK25BwO2YER6gzrh8xsvu+lij230O+KJaB xLiVVZx3Qp1v3CHzhwbDVJ+TUqOyyn7KDF9UcTujblBAMRPkchkLNXfTK/yEgbIJTYVc IYeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BTfJiOV5; 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 q15si1194412eja.87.2020.11.25.05.30.05; Wed, 25 Nov 2020 05:30:29 -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=BTfJiOV5; 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 S1729093AbgKYN0V (ORCPT + 99 others); Wed, 25 Nov 2020 08:26:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727626AbgKYN0V (ORCPT ); Wed, 25 Nov 2020 08:26:21 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F18C0613D4 for ; Wed, 25 Nov 2020 05:26:21 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id e7so1916449wrv.6 for ; Wed, 25 Nov 2020 05:26:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=AlYFyy65mMJrzPAF8ZbtQbw2MzAGfUKKDzhurYImYTg=; b=BTfJiOV5Qs1kwbPh75cNnFXtGarY+41MnAH0XZ7Mmi0dqbPtd7shBqFXYDymd3GNkm lkdahn66M2LPzI/Td7gXSvJfiKph5rGOimnUJgajkNXfkGkhhnIPA4RRxMk2LTmgHb2Q mbfd5dzmX33uNWJIDA46LqcFUM6xlfPDAVQeq/+zCLfloZMl84wadxqfD6mgdQKXCrlr eGZ2McF9rUgTkshK/YzShcNErO8yEsGhUGj12eZkY5cV2c8xFalXfd5xEWQbClJkdz0P G41tzHEcWP3iwW4szgurd8J3PnWzv6UR7faQVwqid6zeIaZATYdS3BwjRTDbasQ+w/uK 72DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AlYFyy65mMJrzPAF8ZbtQbw2MzAGfUKKDzhurYImYTg=; b=uOC78eLqxew73Tk5ozk+95ZsDHLm1cbHQBuVQ+GpB1o+pSMaESDrOpI9bHLkM9U8SA csmNl0tqdIsFGjdZI619RR8JNRYLdE9DUDOgTMke0IUegJr1yDLLuRvINCgxtHM0k0B1 cHmFmgKWHYVTyfjHOXPdumYhwrG8w5QAVbOv+MZnI89oxBOwg8VgBFNS6jOmdN1FUCDC Qxi6rb8vTCFdRcBrL2WRnNxJRGV4VTfsV6B2Lc/yngqbkGgCxDhP4Pme8q/UbJXyCMQQ GcOxYv7JyERj57EeiFsh+w/aow7yyGqF8KFzASL5MfKThQWbLCUd0gFbyR95TwxAN6Yk sF1A== X-Gm-Message-State: AOAM530GOPTZqJe1YiZ57FiAO/SGBAg6GA+j/vkk10kKnmvZi/Ra/KXK xyMkLFrw/L1VQP6xZU0WAaGX5Q== X-Received: by 2002:adf:dd52:: with SMTP id u18mr4022419wrm.44.1606310779648; Wed, 25 Nov 2020 05:26:19 -0800 (PST) Received: from google.com ([2a01:4b00:8523:2d03:38bf:5817:e665:9b9b]) by smtp.gmail.com with ESMTPSA id 90sm5059825wra.95.2020.11.25.05.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 05:26:18 -0800 (PST) Date: Wed, 25 Nov 2020 13:26:17 +0000 From: David Brazdil To: Marc Zyngier Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , Andrew Walbran , kernel-team@android.com Subject: Re: [PATCH v2 04/24] arm64: Move MAIR_EL1_SET to asm/memory.h Message-ID: <20201125132617.qf6vd752dtfasyi7@google.com> References: <20201116204318.63987-1-dbrazdil@google.com> <20201116204318.63987-5-dbrazdil@google.com> <87mtz85geh.wl-maz@kernel.org> <20201125103137.iml7mqpzhylldvqy@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > +/* > > > > + * Memory types available. > > > > + * > > > > + * IMPORTANT: MT_NORMAL must be index 0 since vm_get_page_prot() may 'or' in > > > > + * the MT_NORMAL_TAGGED memory type for PROT_MTE mappings. Note > > > > + * that protection_map[] only contains MT_NORMAL attributes. > > > > + */ > > > > +#define MT_NORMAL 0 > > > > +#define MT_NORMAL_TAGGED 1 > > > > +#define MT_NORMAL_NC 2 > > > > +#define MT_NORMAL_WT 3 > > > > +#define MT_DEVICE_nGnRnE 4 > > > > +#define MT_DEVICE_nGnRE 5 > > > > +#define MT_DEVICE_GRE 6 > > > > + > > > > +/* > > > > + * Default MAIR_ELx. MT_NORMAL_TAGGED is initially mapped as Normal memory and > > > > + * changed during __cpu_setup to Normal Tagged if the system supports MTE. > > > > + */ > > > > +#define MAIR_ELx_SET \ > > > > + (MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRnE, MT_DEVICE_nGnRnE) | \ > > > > + MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRE, MT_DEVICE_nGnRE) | \ > > > > + MAIR_ATTRIDX(MAIR_ATTR_DEVICE_GRE, MT_DEVICE_GRE) | \ > > > > + MAIR_ATTRIDX(MAIR_ATTR_NORMAL_NC, MT_NORMAL_NC) | \ > > > > + MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL) | \ > > > > + MAIR_ATTRIDX(MAIR_ATTR_NORMAL_WT, MT_NORMAL_WT) | \ > > > > + MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL_TAGGED)) > > > > + > > Wait: You now have MAIR_ELx_SET defined at two locations. Surely that's > one too many. > Oops, told you I tried different things... > > > > /* id_aa64isar0 */ > > > > #define ID_AA64ISAR0_RNDR_SHIFT 60 > > > > #define ID_AA64ISAR0_TLB_SHIFT 56 > > > > @@ -992,6 +1020,7 @@ > > > > /* Safe value for MPIDR_EL1: Bit31:RES1, Bit30:U:0, Bit24:MT:0 */ > > > > #define SYS_MPIDR_SAFE_VAL (BIT(31)) > > > > > > > > +#ifndef LINKER_SCRIPT > > > > > > This is terribly ugly. Why is this included by the linker script? Does > > > it actually define __ASSEMBLY__? > > > > vmlinux.lds.S includes memory.h for PAGE_SIZE. And yes, linker scripts > > are > > built with this rule: > > > > cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -U$(ARCH) \ > > -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $< > > > > I tried a few things and wasn't completely happy with any of them. I > > think in > > the previous spin you suggested moving this constant to sysreg.h. That > > works > > too but sysreg.h seems to have only architecture constants, memory.h > > about a > > Linux-specific configuration, so I wanted to keep it here. > > MAIR_ELx_SET isn't really Linux specific. Or rather, not more specific than > any of the other configurations we have. On the other hand, the S1 MT_* > stuff > is totally arbitrary, and does fit in memory.h, together with the rest of > the indexes for the memory types. > > I came up with the following patch on top of this series that seems to > compile without issue. That seems to have an implicit dependency of sysreg.h on memory.h, doesn't it? I had it the other way round initially. I also tried including memory.h in sysreg.h. That creates a circular dependency mmdebug.h -> bug.h -> ... -> sysreg.h -> memory.h -> mmdebug.h. Pretty annoying. I could try to fix that, or create a new header file... :(