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=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 61AB6C2D0E4 for ; Mon, 23 Nov 2020 17:59:40 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE94D206B2 for ; Mon, 23 Nov 2020 17:59:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NCa6545g"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="REg4e9yY"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=marvell.onmicrosoft.com header.i=@marvell.onmicrosoft.com header.b="g/uVQalq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE94D206B2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=marvell.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ogmqdGgKgZP3aBDZi0LjP8MhWEf4EmkUlcU1YDiZzSc=; b=NCa6545gZ++6TpvuJGS15K6Ju A7nlqwz7uNfvxCVfWm4AS6T8Fgy0lrU7g6zYN0cnlEw4+xCWvUnmtj7JnVc/VfPzM8fCH3yOleMe7 D0sjEYEDf3IVzPjMDmwOsnDTfXHMB8xW7XulQ5q6BhReiT6z1By11bnBIlsJW7vqMgFsa6HSuocy6 0SY1OmrK880TUJgDpWkcqEU0r+/e6sTsXrvYQpBjsdRqgGc/mriX33s3CR2ooE1IQQchNM4Zvxavy +STgTzfpGj16r74Kck+rWS5HIaEfJIcc+ITyVu1ko4xR/mM4I3Kz/vV1cYeOvwY+gh2rtE50xKGh9 jZn2njflg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khG6F-0006Bp-4A; Mon, 23 Nov 2020 17:58:03 +0000 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khG6A-0006A2-AP for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2020 17:58:00 +0000 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0ANHskg9021571; Mon, 23 Nov 2020 09:57:23 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=pfpt0220; bh=HNSnwq3BAnQ302ZnxuEdNJkN9rfi2avd1wcD5vME7g4=; b=REg4e9yY7m/V6+LX58L7Y7C/O9qP2m+xXsASAzMGZbTHIOa6IldIXv7z9+T+1Fsm+6f9 OF77iXnM2fyYt6OQGewpFf3MbCxDqNbXyBX/5a8eVvCWdzKa24SHVIkkH3AU+ySKMkle Jjhq01zggIafG7l+UW3ZrlT9Apdf1whZTk1/FHCorPGMGXvx7YIC2/WimdyqjRPZ82jk WDtOobR5R3XPTjq2sXzB1ZbfyZoMzUk/xrwLPW9//hQnXK+3Gl/Fi76J7Z5fWSQPBLRB oJciCjL731eHZ4F6FdRZmAJ7i01bCIit1R+0EKvUDa1eE2nPmNsCDOyEG8lDgHnd2AgX 1w== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 34y39r6dgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 23 Nov 2020 09:57:23 -0800 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 23 Nov 2020 09:57:21 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Mon, 23 Nov 2020 09:57:21 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KSS4jWIynv3ow4UseirWsqRyNxouPFXHoa7DXf3yM8PPgYE9JffeMlx0hqNxKz+4JLUNnyY7wPRgTsrh6/CvOADC0+sQk7CIFZPJaGpyUG+ar3Vy0hhEvyEUDnmNgG9wTTUNeTZmadplD/idZc/J1+FIa7YbKSpQfLLJHutGxJDAqff7FNx+EbhDtdF23h45mq6qap7mhuZ3jT35dxbBB1FfnLlzbRPNaIcXyop1Jg9VcjW+h88cveBKw6VMvema2ZJnOLHTXVZJvTwV8AnBORSH4ARA806PTfapkFDua82l14QquSl4z6/7qw8HcrtaS0yF+/MeA1xRX8cDgwyqMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HNSnwq3BAnQ302ZnxuEdNJkN9rfi2avd1wcD5vME7g4=; b=fzD3V63KyW2P7NOPh6rUoXP7i7RU7PFCsnbDulr4Ax4UnXNTBujn9PiaMvMpu/k4qf2i2XwWyFpADQzIsmoUZADSLr5GJNAC6lTpsSPpfSWdBDDj+uZM09BW/KWbuukqiNdHn66Rt8g/XddJrDdyOn+ecmcOC04/T2PmwbR87tIpGXI4+PWQ6dLb14PGiR/hwfoAM73Myg5Z/T9FPaR51kcO77E1KOOTRJIx4uHxEkWB7+Dka5c1Imv8MBBhbsvNT6DBXVNgRvpLh2IPIXf9lB/tltZFjSgy3C52Pu+iY0OxeLMKA+i4ElBnEEIFEc60dSo96GYCaVVepdDi+jGhig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HNSnwq3BAnQ302ZnxuEdNJkN9rfi2avd1wcD5vME7g4=; b=g/uVQalqr4vxFXRd8dMYyGA0jb7c4EjXi99MHsUwlndQtvvfIHnzgL4x6MTGRC+oeOYfFSq3gVGw2f18PIdA5IFk4bS7STB32CdZ8+EeSWlklIoYlHjq1m+0+6AQPb+7xEFa7Kj9lswBevWEJffIaRScOMPdJInetRWp7iNchc0= Received: from MW2PR18MB2267.namprd18.prod.outlook.com (2603:10b6:907:3::11) by MW3PR18MB3530.namprd18.prod.outlook.com (2603:10b6:303:55::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Mon, 23 Nov 2020 17:57:20 +0000 Received: from MW2PR18MB2267.namprd18.prod.outlook.com ([fe80::e17f:37fb:4eb3:c703]) by MW2PR18MB2267.namprd18.prod.outlook.com ([fe80::e17f:37fb:4eb3:c703%4]) with mapi id 15.20.3564.039; Mon, 23 Nov 2020 17:57:18 +0000 From: Alex Belits To: "nitesh@redhat.com" , "frederic@kernel.org" Subject: [PATCH v5 4/9] task_isolation: Add task isolation hooks to arch-independent code Thread-Topic: [PATCH v5 4/9] task_isolation: Add task isolation hooks to arch-independent code Thread-Index: AQHWwcIVoVPtc0KJ9ES4lz5Mtce9+Q== Date: Mon, 23 Nov 2020 17:57:18 +0000 Message-ID: References: <8d887e59ca713726f4fcb25a316e1e932b02823e.camel@marvell.com> In-Reply-To: <8d887e59ca713726f4fcb25a316e1e932b02823e.camel@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=marvell.com; x-originating-ip: [173.228.7.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bbf22c39-c559-4e26-479c-08d88fd93806 x-ms-traffictypediagnostic: MW3PR18MB3530: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: r5zHGgBN6rk0BYC8zo5dgzzvLoF6x6wCmgBpkLF7VKl4BDS0EvnHeY0Yjn8jXmg+R2I28oatFpz4BEPhzGjPS04dgmhECmoyWNS7zxzvBtX5tqvUv/KRqQZDOUVQxt43aRJAlfs3KYbd/FfS7nqJa2kfk9MqX6Us4FCYROFbqDt0tdh7wRvGy/JpOEaLvIdB6GG88sNJfZp2Y2yIML+28TLV0ZrDDUUyr4965XuW86ZvT1XUCHtCRZjAnc8hIxuNjLBObu7oiYMqAEzdBTQrlfy9nQGLs3139VEydqPg3ky5yAIWu5yuaJtPj0oA/c0RoZ+AjcOALx5I5IB9R8sZag== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR18MB2267.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(39860400002)(136003)(396003)(2906002)(2616005)(71200400001)(5660300002)(6512007)(83380400001)(110136005)(26005)(54906003)(6486002)(186003)(6506007)(36756003)(66946007)(8676002)(316002)(478600001)(8936002)(86362001)(7416002)(66476007)(66556008)(64756008)(66446008)(91956017)(76116006)(4326008); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: eoKw0E7BgzlSVvx+l62a0GeA2uPmmXiNpCSZEeGT+FblCpTJS61eyeUDW3eFJW6O5nVi3TL/pUu+3luz0WSh58PlNX3FTbMi2kywvLslTwS0qTlPSSWWim1Z2S2EDeQ+QSC3hx+iIiEzmwXwptf4zngmzdCuFD3UMysZ6BFWUlqyAQ1O/qt3u4otp/jpDTVdSNueli7PXo3rEDNlhfWi5WUFno0MYoM1QFih0yiXOa0e3Q0qVnDcmXsQhAzHQteYulP5djF2s2VP9XgLGipTgzZfXsAqS8JrWAqx0gTVZiISp9U2mAo0GYStMrF5uGq7WOIxtk4APs+qYEBf2O6LafRTAfXIa0lv/AtGAJk2E6iqkvtgVHnYVY5GU8MVhXIOFhWKzlgSeTRIQ61U8gLdwwjNwpnOzE9KQcqAllm3JyVbkpzxGrl4WX/MOnb65uxaEqQMn6iO+zbC8FjQtxPEEVN/CEAoY9UCjUhvyIfdBKx0vg9Vjr59tYi3Gk7+HX1FXCqgZwBOXUd6HTTJ4CCiWxttkS0oLOZq45azwj2NTpVBljNEqb9WyNPuJZRmQpMZq+uV9jsX+Q/savjTuoYf+x6AeRggTz77/nVyBveah2BRyhTQ2hmhGd0NRyz9h7e9H6r8AUtPjScl2L77zdbki80xzBs5Erbw+FbEA4v8g3vMOm5fWIXLE7pTyTSR8fUE/xIInh3oyHX3+rkKA6bTB4kuWyoLrk9GyZ1AisGsatdXABsOW5vHk20TUEagqM/CZQUs4nE7dXBof7WC1rYBPFT51QRlaL6Jx5f9xvnN3fYnQ9RAiHiHE4Po1nvEZdYhHa17qugGI8NaukchxZGJezoT373kcyC3qTx8bfYntGm03PmXdWsuN8/GHDCa68qLVsgX39OMcE12dsH38u7idQ== Content-ID: <2303373E2A551D43B55A2519D2C99F04@namprd18.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW2PR18MB2267.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bbf22c39-c559-4e26-479c-08d88fd93806 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Nov 2020 17:57:18.1527 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: +tEO1zdHbjRS2TOLmUbfG8U44gAaeEPhM8mfi1Zgu5QbLk4yr8Hute1HKD1uNngjar5U7NnVPPi01K9eVWP/xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR18MB3530 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-23_17:2020-11-23, 2020-11-23 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201123_125758_453538_499D64D1 X-CRM114-Status: GOOD ( 22.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-arch@vger.kernel.org" , "pauld@redhat.com" , "catalin.marinas@arm.com" , "peterz@infradead.org" , Prasun Kapoor , "mtosatti@redhat.com" , "linux-kernel@vger.kernel.org" , "rostedt@goodmis.org" , "davem@davemloft.net" , "leon@sidebranch.com" , "netdev@vger.kernel.org" , "peterx@redhat.com" , "trix@redhat.com" , "tglx@linutronix.de" , "linux-api@vger.kernel.org" , "will@kernel.org" , "mingo@kernel.org" , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Kernel entry and exit functions for task isolation are added to context tracking and common entry points. Common handling of pending work on exit to userspace now processes isolation breaking, cleanup and start. Signed-off-by: Chris Metcalf [abelits@marvell.com: adapted for kernel 5.10] Signed-off-by: Alex Belits --- include/linux/hardirq.h | 2 ++ include/linux/sched.h | 2 ++ kernel/context_tracking.c | 5 +++++ kernel/entry/common.c | 10 +++++++++- kernel/irq/irqdesc.c | 5 +++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h index 754f67ac4326..b9e604ae6a0d 100644 --- a/include/linux/hardirq.h +++ b/include/linux/hardirq.h @@ -7,6 +7,7 @@ #include #include #include +#include #include extern void synchronize_irq(unsigned int irq); @@ -115,6 +116,7 @@ extern void rcu_nmi_exit(void); do { \ lockdep_off(); \ arch_nmi_enter(); \ + task_isolation_kernel_enter(); \ printk_nmi_enter(); \ BUG_ON(in_nmi() == NMI_MASK); \ __preempt_count_add(NMI_OFFSET + HARDIRQ_OFFSET); \ diff --git a/include/linux/sched.h b/include/linux/sched.h index 5d8b17aa544b..51c2d774250b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -34,6 +34,7 @@ #include #include #include +#include /* task_struct member predeclarations (sorted alphabetically): */ struct audit_context; @@ -1762,6 +1763,7 @@ extern char *__get_task_comm(char *to, size_t len, struct task_struct *tsk); #ifdef CONFIG_SMP static __always_inline void scheduler_ipi(void) { + task_isolation_kernel_enter(); /* * Fold TIF_NEED_RESCHED into the preempt_count; anybody setting * TIF_NEED_RESCHED remotely (for the first time) will also send diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index 36a98c48aedc..379a48fd0e65 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c @@ -21,6 +21,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -100,6 +101,8 @@ void noinstr __context_tracking_enter(enum ctx_state state) __this_cpu_write(context_tracking.state, state); } context_tracking_recursion_exit(); + + task_isolation_exit_to_user_mode(); } EXPORT_SYMBOL_GPL(__context_tracking_enter); @@ -148,6 +151,8 @@ void noinstr __context_tracking_exit(enum ctx_state state) if (!context_tracking_recursion_enter()) return; + task_isolation_kernel_enter(); + if (__this_cpu_read(context_tracking.state) == state) { if (__this_cpu_read(context_tracking.active)) { /* diff --git a/kernel/entry/common.c b/kernel/entry/common.c index e9e2df3f3f9e..10a520894105 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -4,6 +4,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -183,13 +184,20 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, static void exit_to_user_mode_prepare(struct pt_regs *regs) { - unsigned long ti_work = READ_ONCE(current_thread_info()->flags); + unsigned long ti_work; lockdep_assert_irqs_disabled(); + task_isolation_before_pending_work_check(); + + ti_work = READ_ONCE(current_thread_info()->flags); + if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK)) ti_work = exit_to_user_mode_loop(regs, ti_work); + if (unlikely(ti_work & _TIF_TASK_ISOLATION)) + task_isolation_start(); + arch_exit_to_user_mode_prepare(regs, ti_work); /* Ensure that the address limit is intact and no locks are held */ diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 1a7723604399..b8f0a7574f55 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "internals.h" @@ -669,6 +670,8 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, unsigned int irq = hwirq; int ret = 0; + task_isolation_kernel_enter(); + irq_enter(); #ifdef CONFIG_IRQ_DOMAIN @@ -710,6 +713,8 @@ int handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq, unsigned int irq; int ret = 0; + task_isolation_kernel_enter(); + /* * NMI context needs to be setup earlier in order to deal with tracing. */ -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel