From patchwork Wed Mar 12 04:06:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 14012839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EADB3C2BA1B for ; Wed, 12 Mar 2025 04:07:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.909672.1316590 (Exim 4.92) (envelope-from ) id 1tsDNA-0007cf-8K; Wed, 12 Mar 2025 04:07:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 909672.1316590; Wed, 12 Mar 2025 04:07:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tsDNA-0007cY-4O; Wed, 12 Mar 2025 04:07:12 +0000 Received: by outflank-mailman (input) for mailman id 909672; Wed, 12 Mar 2025 04:07:11 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tsDN9-0006o2-50 for xen-devel@lists.xenproject.org; Wed, 12 Mar 2025 04:07:11 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062b.outbound.protection.outlook.com [2a01:111:f403:200a::62b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 76d9b4e1-fef7-11ef-9898-31a8f345e629; Wed, 12 Mar 2025 05:07:09 +0100 (CET) Received: from BN0PR02CA0015.namprd02.prod.outlook.com (2603:10b6:408:e4::20) by IA0PPFAF883AE17.namprd12.prod.outlook.com (2603:10b6:20f:fc04::be1) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8511.28; Wed, 12 Mar 2025 04:07:03 +0000 Received: from BN1PEPF00006002.namprd05.prod.outlook.com (2603:10b6:408:e4:cafe::e9) by BN0PR02CA0015.outlook.office365.com (2603:10b6:408:e4::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.21 via Frontend Transport; Wed, 12 Mar 2025 04:07:03 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF00006002.mail.protection.outlook.com (10.167.243.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8534.20 via Frontend Transport; Wed, 12 Mar 2025 04:07:03 +0000 Received: from penny-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 11 Mar 2025 23:06:59 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 76d9b4e1-fef7-11ef-9898-31a8f345e629 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MWQmTq78xCvWDdrXeBmv6ibx0YsGReARteo1t6cC4v8UvAn6L8KFTac3ISE2tKa+lBRFcOtR14oAlvqzoCV43dsNDyBgMauJA5VCPpxR4CGEf/dFy6uRxUFkx3jJHhmCbFm6LmMAOvuRNiBcbYctWSG0Y9DT3fa9gxgWBDqimhuqYKR+dOwZEuAJEUqxN/eooZP6uL1+ZJXVfyo1q8OZ1i3j/KPmt9CYJIvxmwSt2pnGuykV4ypJq1hiJJlu96rdCEL9k2X+AF1ycA/KJyQ+S48VSxO0mWitNGLnNoW3gUiLAPFHbKaQUG2J6/YRUWZFSyP56dSqTPX6YzZ76391Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hfJvd41dMivz5QRFtPQPjoU8VhwHzIPONjPe2MQlcts=; b=PymuyoOysdLP2dldS3Tt9E9ZMEhZ8dhxDkHxYcOmMZgBtBRHebEh5nl/FyDJjBhRf4u2MvH8Fe8J5rvesJg0aZi8g302XTd/fNAHcX5yRSBrZ1e0pn+ihRlx//fh4B83bfiE/UPyyDG2tn6INhEZyeKj5pZ9oagDKmfV7N/3RiCCAHfGhBykBnnWG5IMWeUzVdXt3HRicJ/GeLaKwb4wdwJYsHMdOFRyBrUSV8+BffE+/R2GsKA07nQuyGEq6hsI57aidyU5Q4PzHfSgAl4dgc+pI6N+SEZZ0a4KDKWS/leS4fV846p5M+D9TjS1b5+vg2gQd0CyPAU4ZHD7XqDjqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hfJvd41dMivz5QRFtPQPjoU8VhwHzIPONjPe2MQlcts=; b=n+gy4BodC8GBmQti5umGZ8jhtF46DboCYbK6z6rmqL0Jli/HT4cKiEP5rqHrhCp3Du2M8W17de9QXNPHebnBJEo6BcxBjYSd508kjSCYNOz6f2qDL3GvFzM31cLbZpVlwcjE1rp6mg0PiMIH0Gf6jfu90dwOWxP40DkU7XssF2c= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Penny Zheng To: CC: , Penny Zheng , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , "Julien Grall" , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , "Daniel P. Smith" Subject: [PATCH v1 03/19] xen/sysctl: wrap around XEN_SYSCTL_readconsole Date: Wed, 12 Mar 2025 12:06:16 +0800 Message-ID: <20250312040632.2853485-4-Penny.Zheng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250312040632.2853485-1-Penny.Zheng@amd.com> References: <20250312040632.2853485-1-Penny.Zheng@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00006002:EE_|IA0PPFAF883AE17:EE_ X-MS-Office365-Filtering-Correlation-Id: 9343d474-6fc9-4d37-4a2b-08dd611b58d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: AT32nOezBV3/d3k8muScHV5l5VPFzI6CYIwoioMVcDJHGA77DSfpzWGhT5Akx3r3N2Zs23hzWcY4JtUkBUu4Jrqb52mS7d1FBp9NYaO5sgZwg6hVWVlPjJ1OE65BpQNrqUO6hZN6ETLAbq/aortkNiUL08DA/bgvDr1S7qwSYOUeLirbgd+c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T05m30FrJLBeXxpRns8LBM1vSnoF+gzz4f5VU8XSepMdLjAB6rP+/T99XQOSAEGhbChO679w8iLLRFAamUHobO04kkAoQ9N+/Brq3g7IA4cAYR6wxxo+UaD4YiS4NUspXKotUpnFVoxHRHj5nWFgMnBsVuvzD59krl64LWZJRE4avd/wjAmHeRWmG4UgJjQfa/Pc4AIIt05+LZc9Aora40eY7BWJbdDxpBrhB0zGI1nIh3gcE4FM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2025 04:07:03.8328 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9343d474-6fc9-4d37-4a2b-08dd611b58d4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00006002.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PPFAF883AE17 The following functions is to deal with XEN_SYSCTL_readconsole sub-op, and shall be wrapped: - xsm_readconsole - read_console_ring Signed-off-by: Penny Zheng --- xen/drivers/char/console.c | 2 ++ xen/include/xen/console.h | 8 ++++++++ xen/include/xsm/dummy.h | 11 ++++++++--- xen/include/xsm/xsm.h | 11 ++++++++--- xen/xsm/dummy.c | 2 +- xen/xsm/flask/hooks.c | 4 ++-- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 2f028c5d44..6e4f3c4659 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -336,6 +336,7 @@ static void conring_puts(const char *str, size_t len) conringc = conringp - conring_size; } +#ifdef CONFIG_SYSCTL long read_console_ring(struct xen_sysctl_readconsole *op) { XEN_GUEST_HANDLE_PARAM(char) str; @@ -378,6 +379,7 @@ long read_console_ring(struct xen_sysctl_readconsole *op) return 0; } +#endif /* CONFIG_SYSCTL */ /* diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h index 83cbc9fbda..e7d5063d82 100644 --- a/xen/include/xen/console.h +++ b/xen/include/xen/console.h @@ -7,12 +7,20 @@ #ifndef __CONSOLE_H__ #define __CONSOLE_H__ +#include #include #include #include struct xen_sysctl_readconsole; +#ifdef CONFIG_SYSCTL long read_console_ring(struct xen_sysctl_readconsole *op); +#else +static inline long read_console_ring(struct xen_sysctl_readconsole *op) +{ + return -EOPNOTSUPP; +} +#endif void console_init_preirq(void); void console_init_ring(void); diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index afc54a0b2f..35d084aca7 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -186,18 +186,23 @@ static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd) XSM_ASSERT_ACTION(XSM_PRIV); return xsm_default_action(action, current->domain, NULL); } + +static XSM_INLINE int cf_check xsm_readconsole(XSM_DEFAULT_ARG uint32_t clear) +{ + XSM_ASSERT_ACTION(XSM_HOOK); + return xsm_default_action(action, current->domain, NULL); +} #else static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd) { return -EOPNOTSUPP; } -#endif static XSM_INLINE int cf_check xsm_readconsole(XSM_DEFAULT_ARG uint32_t clear) { - XSM_ASSERT_ACTION(XSM_HOOK); - return xsm_default_action(action, current->domain, NULL); + return -EOPNOTSUPP; } +#endif /* CONFIG_SYSCTL */ static XSM_INLINE int cf_check xsm_alloc_security_domain(struct domain *d) { diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 276507b515..d322740de1 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -62,8 +62,8 @@ struct xsm_ops { int (*domctl)(struct domain *d, unsigned int cmd, uint32_t ssidref); #ifdef CONFIG_SYSCTL int (*sysctl)(int cmd); -#endif int (*readconsole)(uint32_t clear); +#endif int (*evtchn_unbound)(struct domain *d, struct evtchn *chn, domid_t id2); int (*evtchn_interdomain)(struct domain *d1, struct evtchn *chn1, @@ -266,17 +266,22 @@ static inline int xsm_sysctl(xsm_default_t def, int cmd) { return alternative_call(xsm_ops.sysctl, cmd); } + +static inline int xsm_readconsole(xsm_default_t def, uint32_t clear) +{ + return alternative_call(xsm_ops.readconsole, clear); +} #else static inline int xsm_sysctl(xsm_default_t def, int cmd) { return -EOPNOTSUPP; } -#endif static inline int xsm_readconsole(xsm_default_t def, uint32_t clear) { - return alternative_call(xsm_ops.readconsole, clear); + return -EOPNOTSUPP; } +#endif static inline int xsm_evtchn_unbound( xsm_default_t def, struct domain *d1, struct evtchn *chn, domid_t id2) diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index 0a5fc06bbf..4c97db0c48 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -24,8 +24,8 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .domctl = xsm_domctl, #ifdef CONFIG_SYSCTL .sysctl = xsm_sysctl, -#endif .readconsole = xsm_readconsole, +#endif .evtchn_unbound = xsm_evtchn_unbound, .evtchn_interdomain = xsm_evtchn_interdomain, diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 7c5e7f5879..7c46657d97 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -934,7 +934,6 @@ static int cf_check flask_sysctl(int cmd) return avc_unknown_permission("sysctl", cmd); } } -#endif static int cf_check flask_readconsole(uint32_t clear) { @@ -945,6 +944,7 @@ static int cf_check flask_readconsole(uint32_t clear) return domain_has_xen(current->domain, perms); } +#endif /* CONFIG_SYSCTL */ static inline uint32_t resource_to_perm(uint8_t access) { @@ -1888,8 +1888,8 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = { .domctl = flask_domctl, #ifdef CONFIG_SYSCTL .sysctl = flask_sysctl, -#endif .readconsole = flask_readconsole, +#endif .evtchn_unbound = flask_evtchn_unbound, .evtchn_interdomain = flask_evtchn_interdomain,