Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp723472lqj; Sun, 2 Jun 2024 20:27:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIc3hyqZO+3xE3BMC+R6JiRQX6DZVfGdhggKNfD4Z+Clx1JmE+gbJXnCaV+TywslfajwvU+wQRfz6zF2EdCeQ7Al3pIN67/bZ9NJQ9fQ== X-Google-Smtp-Source: AGHT+IHcjD52HoamhRH74irNsL45IT1sUcEp/AQ8Bv6Kznzjy3eRnnWJ0YSaQhWPfLy/bdYbGYdU X-Received: by 2002:a05:6870:d626:b0:24f:c892:d02b with SMTP id 586e51a60fabf-2508b34905fmr8019240fac.0.1717385249829; Sun, 02 Jun 2024 20:27:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717385249; cv=pass; d=google.com; s=arc-20160816; b=uM5P3e2tDxUqKHj9DWyRkVSracAFKaB3p9U78UgYWVjsg2OHwl9/BypF1p1G/LZrsI Ejk43Nur+ADvhu9mGQFB6jQV+DRkIAgXVxFzhTog5On/MAM5J6T8hZo/U0ULQLPD6ZXR i51kCqrQvboZ6gjZPuarCxnXiEF8z10iTtRygh0k07ODS8taBytLrmmc34OV6QFr5W2L vixaVCZTdQZeziAf49X/d1e80cQ60gazf99YDC1InCSR5PZw2rZ4nCifah2JMl6TIpsA iWTJo030dcMlznZfl5euaONyFNfzJHhCZD2BSdhBOsM+k8c14W8V1Cp3YCJ0DqJwxuid s11A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=z7HoitklBGxs6OWFqvyxWd8N2VJyI7guvKgrT5l7L/4=; fh=kVtozVL1euXPaXBltq9PHxfUjHhLO3/NBPq3XAWwMlc=; b=wxX3O5S7mplxV/2DybOgBVX0NpxDh7rRZM9AJ3YMo1Bw9IP9BxjL2so0RCjmVPv3o8 zW58ILh2QalQkbh8GXNr/fJ5EPTHaeAnTBVv5MXArqzc8BBPGrvDiZBEmJP4W5ip0iEu KyA1RxPQOv1jX89y6v2UWTCIh7o+vQY2sj5eI4KBo9fLGPcLO19ecrwRG0e7DTKeVkjw eyS234EPi1Ezy+d60qudRUvLSA6Io8TY9zlh/pK564yTuKEuSLSCkVPXYBMU1IslfEwH 78fFmKjLSzEHxuLk4M7J/cgY3jdqueVc/XLonrJAv8ggMhlPXrCrHFkzbd1eGHa1A1II YJUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-198572-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198572-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-702425e6cb9si5805750b3a.26.2024.06.02.20.27.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 20:27:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198572-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-198572-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198572-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 87454B20D91 for ; Mon, 3 Jun 2024 03:27:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D75A7F9E9; Mon, 3 Jun 2024 03:26:52 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B461FEAD7 for ; Mon, 3 Jun 2024 03:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717385212; cv=none; b=hGsmY4PNKn8yUDPzES5gYt9+iuUgkj3tuCSNGaH3wn8wZLHllohySh2kbQ2bGc/J+U1c2r4Uk1hNA8IYi1Re+ND8om5rU4fD1De/9N1z4M7POv+mF74BZkn77VBbMDixeB1GQz+i8BHL4ZVTTZERqKWHj6za5gWQrog/YZTy9bY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717385212; c=relaxed/simple; bh=4AxKANIPQDldK4oFGsXikmc5DVLnqvzkXVQP6Ec3lKs=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=OFYUPlOd3Y7AAa12/QJ9Htr4LPpnhC30fIBEO7cz0qdNDqNRejuUioyddy0zWZcYvb1LO9jJ6RebgjM1pogPABq+HkXMdN/Xu4OETw0ZCnqs58lSM/Tx3zj2EjeqmW2msdtX6eTIrn7MXF4cV84JfrYBZ0HVBVBsKXA2Ufn6+pk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VszYz3Y5CzxRJd; Mon, 3 Jun 2024 11:22:47 +0800 (CST) Received: from kwepemd200013.china.huawei.com (unknown [7.221.188.133]) by mail.maildlp.com (Postfix) with ESMTPS id B3C08180085; Mon, 3 Jun 2024 11:26:41 +0800 (CST) Received: from [10.67.110.108] (10.67.110.108) by kwepemd200013.china.huawei.com (7.221.188.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 3 Jun 2024 11:26:40 +0800 Message-ID: Date: Mon, 3 Jun 2024 11:26:39 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH v3 1/8] arm64/sysreg: Add definitions for immediate versions of MSR ALLINT To: Mark Brown CC: Mark Rutland , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20240415064758.3250209-1-liaochang1@huawei.com> <20240415064758.3250209-2-liaochang1@huawei.com> From: "Liao, Chang" In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd200013.china.huawei.com (7.221.188.133) Hi, Mark 在 2024/5/7 22:52, Mark Brown 写道: > On Tue, May 07, 2024 at 03:41:08PM +0800, Liao, Chang wrote: >> 在 2024/5/6 23:15, Mark Brown 写道: >>> On Fri, May 03, 2024 at 05:00:49PM +0100, Mark Rutland wrote: > >>>> +#define set_pstate_allint(x) asm volatile(SET_PSTATE_ALLINT(x)) > >>> Hrm, those helpers are not ideally discoverable, partly due to the >>> system register description for ALLINT not providing any references to >>> this being a general scheme (which is fixable there) and partly due to > >> Based on the Arm ISA reference manual, the instruction accessing the ALLINT >> field of PSTATE uses the following encoding: > > I'm not saying the suggestion is wrong, I'm saying that between the ARM > and the way the code is written the helpers aren't as discoverable as > they should be, like I say from a code point of view that's mainly > because... > >> op0 op1 CRn CRm op2 >> MSR ALLINT, # 0b00 0b001 0b0100 0b000x 0b000 > > ...we only have the encoding for the MSR and don't mention the letters > 'msr' anywhere. We should improve that to say what we're encoding in > the code (in general I'd say that's true for any __emit_inst(), not just > these ones). Oh, I apologize any confusion in my previous message. Mark, Is your concern is that the series of pstate related macro name in sysregs.h are lack of self-explanatory nature, which make it diffuclt to understand their functionality and purpose? If so, I daft some alternative macro names in the code below, looking forward to your feedback, or if you have any proposal for making these helpers discoverable. ----8<---- diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 643e2ad73cbd..4f514bdfb1bd 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -90,7 +90,7 @@ */ #define pstate_field(op1, op2) ((op1) << Op1_shift | (op2) << Op2_shift) #define PSTATE_Imm_shift CRm_shift -#define SET_PSTATE(x, r) __emit_inst(0xd500401f | PSTATE_ ## r | ((!!x) << PSTATE_Imm_shift)) +#define MSR_PSTATE_ENCODE(x, r) __emit_inst(0xd500401f | PSTATE_ ## r | ((!!x) << PSTATE_Imm_shift)) #define PSTATE_PAN pstate_field(0, 4) #define PSTATE_UAO pstate_field(0, 3) @@ -99,18 +99,18 @@ #define PSTATE_TCO pstate_field(3, 4) #define PSTATE_ALLINT pstate_field(1, 0) -#define SET_PSTATE_PAN(x) SET_PSTATE((x), PAN) -#define SET_PSTATE_UAO(x) SET_PSTATE((x), UAO) -#define SET_PSTATE_SSBS(x) SET_PSTATE((x), SSBS) -#define SET_PSTATE_DIT(x) SET_PSTATE((x), DIT) -#define SET_PSTATE_TCO(x) SET_PSTATE((x), TCO) -#define SET_PSTATE_ALLINT(x) SET_PSTATE((x), ALLINT) - -#define set_pstate_pan(x) asm volatile(SET_PSTATE_PAN(x)) -#define set_pstate_uao(x) asm volatile(SET_PSTATE_UAO(x)) -#define set_pstate_ssbs(x) asm volatile(SET_PSTATE_SSBS(x)) -#define set_pstate_dit(x) asm volatile(SET_PSTATE_DIT(x)) -#define set_pstate_allint(x) asm volatile(SET_PSTATE_ALLINT(x)) +#define MSR_PSTATE_PAN(x) MSR_PSTATE_ENCODE((x), PAN) +#define MSR_PSTATE_UAO(x) MSR_PSTATE_ENCODE((x), UAO) +#define MSR_PSTATE_SSBS(x) MSR_PSTATE_ENCODE((x), SSBS) +#define MSR_PSTATE_DIT(x) MSR_PSTATE_ENCODE((x), DIT) +#define MSR_PSTATE_TCO(x) MSR_PSTATE_ENCODE((x), TCO) +#define MSR_PSTATE_ALLINT(x) MSR_PSTATE_ENCODE((x), ALLINT) + +#define msr_pstate_pan(x) asm volatile(MSR_PSTATE_PAN(x)) +#define msr_pstate_uao(x) asm volatile(MSR_PSTATE_UAO(x)) +#define msr_pstate_ssbs(x) asm volatile(MSR_PSTATE_SSBS(x)) +#define msr_pstate_dit(x) asm volatile(MSR_PSTATE_DIT(x)) +#define msr_pstate_allint(x) asm volatile(MSR_PSTATE_ALLINT(x)) ---->8---- Thanks. -- BR Liao, Chang