Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755715AbcCBU01 (ORCPT ); Wed, 2 Mar 2016 15:26:27 -0500 Received: from mail-am1on0096.outbound.protection.outlook.com ([157.56.112.96]:55177 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755215AbcCBU0Z (ORCPT ); Wed, 2 Mar 2016 15:26:25 -0500 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none;ezchip.com; dmarc=none action=none header.from=ezchip.com; From: Chris Metcalf To: Gilad Ben Yossef , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andrew Morton , "Rik van Riel" , Tejun Heo , Frederic Weisbecker , Thomas Gleixner , "Paul E. McKenney" , Christoph Lameter , Viresh Kumar , Catalin Marinas , Will Deacon , Andy Lutomirski , CC: Chris Metcalf Subject: [PATCH v10 10/12] arch/tile: enable task isolation functionality Date: Wed, 2 Mar 2016 15:09:34 -0500 Message-ID: <1456949376-4910-11-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1456949376-4910-1-git-send-email-cmetcalf@ezchip.com> References: <1456949376-4910-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11OLC006;1:6sDEpn7dMnV9i5eK2kcY9+kfCMdQTyxxalOEoSERBeECX4GIubnmSQU+7yRF1dZkmlnlibdEt2wnsM8zJAxkxjVE43uiz8QpcgMIQ0GnWvl2qzPtTe5V37HmMN/eBZqeSpBcRrlT9uTqpEHkaUicogg0DuqHpkP5O9Iv0pmkVC8LU2E6sUY49kFZSwhowSTZ6yVrg3QjHoHNZiFRfA/j2l2awjcRHN5z+yK4K5Qvr5SsDdWXsbbdh1xWx/xD5IATdbKpjFokEhUuyG0dLRB9wjzxp5/i+ZA0VvKyebx086OfHVbhMR4rg10M/YSIie395TWhCFq4lRrOsX13sI/mCuGMo5eMeR/Yv5pAt35SyaF/hczLmrBzyShKPq924WcN0nz/nwjkpB2qEJ0jlSVH3bslMwHtVAmfQsYd9Dy6hNYeiJsFYq9Jkk1tA06/59hHSsbRrSjY3BPI+bg6BtCkcIrXNVQB+ILcKfLbR7ozNT8= X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(1109001)(339900001)(199003)(189002)(5001770100001)(42186005)(1220700001)(105606002)(106466001)(33646002)(1096002)(104016004)(6806005)(4326007)(107886002)(11100500001)(48376002)(586003)(5003940100001)(189998001)(19580395003)(2906002)(4001430100002)(81156011)(19580405001)(5008740100001)(50226001)(5001970100001)(92566002)(229853001)(2950100001)(47776003)(85426001)(50986999)(36756003)(76176999)(87936001)(50466002)(921003)(42882005)(1121003)(83996005)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR05MB1693;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 46e97840-c9c6-4ea8-56d3-08d342d6b611 X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1693;2:wXIi1qZfrJIl1aymksF3Gz58m5581mY9dxq2oJnHd07EeW/5NCS9gAqXPpgyeT4mS34hCA70UpbFEw5DtVJ+oyo0cLt8H8qTaHXs3o0Bk3lyMDKt5EFXyofoeHPlwZbBDcdxyg0U4P/EzzhYsRs4h9owqCt/CvhnTFJfqStWJnkvGqnll+ZZYwCy+9y59X2w;3:rsseBYT36UzwkB99aBAZW8E3yMcklZPf/w1jIohAC9DdlHbgIGMbemWiNBMEHwlVhIS38VDJY1o8axs84hs4tLfbid8fwpE7TELDvh2Q/XMAGv6z/5ILgozSsVfA1XSDHZr48u9ZjSAq11EYbu0wuOx6pqjIk8tZKIOZWQ7g+vfMiTCQ34yu6GI6BcHVms6kTHTGHsOnc0uiNzOf2XqXbWbVyBD42sY83OAyhzbeWI0=;25:Pso4BYjxHQJHmit6a8vKigzPmQsRvB3Phvs2/i1MzfX7SUT3tLFR8i1w4TTjawAgaHSxvrAet0DI0akOVk2B5GJbvrrSN46JD2MEN20SRpnstksrt1zYOCPtGFgndr14gfWSRNl18OswVnc2eo67KEDIFp71YFUhvrxZUvTZ/aoVpd417fDCM1GFp7PSem9lBH6xyL9o0s2RoESG4T+czmRI6OlY5i/evCyXXkhv/f21K2L2orDW+vJrI/s9MhFuxZIxSIYsCZZAz2PF/evUiV8IjofA0a0pVSAnE0LJJQnPOht7kEAp4UOqlrg9E7n5MPVH8BaxMKTJDF6q1GO+wA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB1693; X-MLNXRule-EZCH-Linux: Rule triggered X-MLNXRule-Acc-Dom-4: Rule triggered X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1693;20:+bbyfvWE9EM/KreC50nafGUkdeKIQn5wqKm52IYQLHE2T8QYJ9U09i+fV9pX2BXN+TrpZEH6kGTaBksPmLBu/KCweRB+PlrFAlp+tzGdEFg+z6fGBmO5CM2UzUCwTy2Yysm5ovudrEWeYsIKVZeIt6h3MNLYiruQOzVsESm6yHjGJBWXI7ZM4XfyB0Dn6RRPNBP46fvZkGY4X9FmuWi+4boqNGIG7fO0lIfaFK+8dtBE/J3Qs/YCNkg7rxoW8F3oX/PkQ8tNHJ5RNyfc1Dft739kRhw1egjFyyTCT0LkQ1UcYtZ0x7VK2I6U2zQwKM9WSyD1He4qvvtOzbWcny28EEPxWtSHP2BcJtWtDrcz6/WIjGepdNrSIFSou2CMX1SrOu/DhgrWjvpdEjGTiBJp3iMJ8ZXwHzH0Od8UOnhXVq4kZCgkl/xzyiCz/iTWOmrWvhfTpOPk9Gus2YM6I7v0VgBV9F+4txiIcNWc3qOb6cWRZub4YnqdQxScMJdZrqFzVFkCkyXMygWErBmWVLC3LSGnM6tvBM8LNASXLL3AOQu+TpZBBBG8FzEwchOUNx3Po+GOsaVvelmQuPkd9vw/7icESj2QMKe9xC8DjgnAlYU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(5005006)(8121501046)(13018025)(3002001)(10201501046);SRVR:VI1PR05MB1693;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB1693; X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1693;4:+euDlqN6vZSwyO90EVBLKSTQh5RSftJZQl75RGFJLUL0X508lm/3wGDLtWnILMyXWB7/K3NRtbmpLhVbqFOs6Z3WWu7GFepR1YHJAjtNSEMLPTMQCutX0aULPCF476QkKUJb58tG3ufgxZBt7Ji54mO6cI9x/j1HvD37/k2YUHSZY6PpyYPTcBKOiT1OPawShhLMv4AYVDtcPJv6DwN9EIsYdo2U2yuCaHnZPNxoaJzlQtLofCyfWTWDGJXk/bZAQOVhfGoBHLKaNX8tDzYdyTiPgHbaghjAhmbRKjplRGRZ3FpI7QzX+zLvEbaPfHd0Gd52w3slpCsnFnrprBb/QZDLgx6vboV6wu1RN4EWvoOzAFxsJzllfSxQCL8Ugk8+OaWSDkVEtvfdDWGW83hm3LWLu/68HkmiTqmsf8XxuC1yUdFSwqMtPJB+VbHTaoIU7HQztjdhRStmz3KT2CJHOQ== X-Forefront-PRVS: 086943A159 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR05MB1693;23:BpclY9EDFJrS2T2w0/1Q1CTUm57JKbadZKArrotj3?= =?us-ascii?Q?qXr2keNFZED94g4Tb6T3oLTKnd1j3b2QzfbVR04Iucl92lqRn937e6EAyWra?= =?us-ascii?Q?n+p0tfj6hKawwcw0M73xbSSWsZepxgLb5bHlucMoH8SPe//3ZMXw+5oEpwDK?= =?us-ascii?Q?hdZ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svYTw1lkvd+nDlY30iGLQahKdZNe?= =?us-ascii?Q?SswoCG2CyWIajqKamUkwGuCHkyy5pPDdZcY7SsDrKGe5hqSg2o5wJbUz5Cyn?= =?us-ascii?Q?ufmehylJ1JUm5QZchWWFHLnKcPSoc4bICWBG6PYHvRPUKVidEQdpSOlKpqKC?= =?us-ascii?Q?qlauLP0RRBZUQY=3D?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1693;5:RYbdKOPxvGQDe9bWRhfDcDgYpvkykFCZMdJoh9fxXSZA4V0kIyAaT3nnYphh0GILmmhIt+xyGWkTMzOQa+OKdRno28sRP0RB9wxTpZHta9uOOtH1dYbBRgMQDT4zPynak2pshXgzDVIK2+LlyslqHw==;24:R9CKIiAEWav5lIYsknIUEuE3zz/cFVPGPykvPxVSY0ytBto9YaH1kwJPhZ2eGujFjggRkBB3oQALLxVAGJiTllT78x7dyPLB5kvY2XYpvD4= X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2016 20:10:32.9872 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b;Ip=[12.216.194.146];Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1693 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7404 Lines: 243 We add the necessary call to task_isolation_enter() in the prepare_exit_to_usermode() routine. We already unconditionally call into this routine if TIF_NOHZ is set, since that's where we do the user_enter() call. We add calls to task_isolation_check_exception() in places where exceptions may not generate signals to the application. Signed-off-by: Chris Metcalf --- arch/tile/kernel/process.c | 6 +++++- arch/tile/kernel/ptrace.c | 6 ++++++ arch/tile/kernel/single_step.c | 5 +++++ arch/tile/kernel/smp.c | 28 ++++++++++++++++------------ arch/tile/kernel/unaligned.c | 3 +++ arch/tile/mm/fault.c | 3 +++ arch/tile/mm/homecache.c | 2 ++ 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c index 6594df5fed53..8f739f78780c 100644 --- a/arch/tile/kernel/process.c +++ b/arch/tile/kernel/process.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -495,10 +496,13 @@ void prepare_exit_to_usermode(struct pt_regs *regs, u32 thread_info_flags) tracehook_notify_resume(regs); } + task_isolation_enter(); + local_irq_disable(); thread_info_flags = READ_ONCE(current_thread_info()->flags); - } while (thread_info_flags & _TIF_WORK_MASK); + } while ((thread_info_flags & _TIF_WORK_MASK) || + !task_isolation_ready()); if (thread_info_flags & _TIF_SINGLESTEP) { single_step_once(regs); diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c index 54e7b723db99..f76f2d8b8923 100644 --- a/arch/tile/kernel/ptrace.c +++ b/arch/tile/kernel/ptrace.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -255,6 +256,11 @@ int do_syscall_trace_enter(struct pt_regs *regs) { u32 work = ACCESS_ONCE(current_thread_info()->flags); + if (work & _TIF_NOHZ) { + if (task_isolation_check_syscall(regs->regs[TREG_SYSCALL_NR])) + return -1; + } + if (secure_computing() == -1) return -1; diff --git a/arch/tile/kernel/single_step.c b/arch/tile/kernel/single_step.c index 862973074bf9..ba01eacde7a3 100644 --- a/arch/tile/kernel/single_step.c +++ b/arch/tile/kernel/single_step.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -320,6 +321,8 @@ void single_step_once(struct pt_regs *regs) int size = 0, sign_ext = 0; /* happy compiler */ int align_ctl; + task_isolation_check_exception("single step at %#lx", regs->pc); + align_ctl = unaligned_fixup; switch (task_thread_info(current)->align_ctl) { case PR_UNALIGN_NOPRINT: @@ -767,6 +770,8 @@ void single_step_once(struct pt_regs *regs) unsigned long *ss_pc = this_cpu_ptr(&ss_saved_pc); unsigned long control = __insn_mfspr(SPR_SINGLE_STEP_CONTROL_K); + task_isolation_check_exception("single step at %#lx", regs->pc); + *ss_pc = regs->pc; control |= SPR_SINGLE_STEP_CONTROL_1__CANCELED_MASK; control |= SPR_SINGLE_STEP_CONTROL_1__INHIBIT_MASK; diff --git a/arch/tile/kernel/smp.c b/arch/tile/kernel/smp.c index 07e3ff5cc740..da1eb240fc57 100644 --- a/arch/tile/kernel/smp.c +++ b/arch/tile/kernel/smp.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -67,6 +68,7 @@ void send_IPI_single(int cpu, int tag) .x = cpu % smp_width, .state = HV_TO_BE_SENT }; + task_isolation_debug(cpu); __send_IPI_many(&recip, 1, tag); } @@ -84,6 +86,7 @@ void send_IPI_many(const struct cpumask *mask, int tag) r->x = cpu % smp_width; r->state = HV_TO_BE_SENT; } + task_isolation_debug_cpumask(mask); __send_IPI_many(recip, nrecip, tag); } @@ -181,10 +184,11 @@ void flush_icache_range(unsigned long start, unsigned long end) struct ipi_flush flush = { start, end }; /* If invoked with irqs disabled, we can not issue IPIs. */ - if (irqs_disabled()) + if (irqs_disabled()) { + task_isolation_debug_cpumask(task_isolation_map); flush_remote(0, HV_FLUSH_EVICT_L1I, NULL, 0, 0, 0, NULL, NULL, 0); - else { + } else { preempt_disable(); on_each_cpu(ipi_flush_icache_range, &flush, 1); preempt_enable(); @@ -258,10 +262,8 @@ void __init ipi_init(void) #if CHIP_HAS_IPI() -void smp_send_reschedule(int cpu) +static void __smp_send_reschedule(int cpu) { - WARN_ON(cpu_is_offline(cpu)); - /* * We just want to do an MMIO store. The traditional writeq() * functions aren't really correct here, since they're always @@ -273,15 +275,17 @@ void smp_send_reschedule(int cpu) #else -void smp_send_reschedule(int cpu) +static void __smp_send_reschedule(int cpu) { - HV_Coord coord; - - WARN_ON(cpu_is_offline(cpu)); - - coord.y = cpu_y(cpu); - coord.x = cpu_x(cpu); + HV_Coord coord = { .y = cpu_y(cpu), .x = cpu_x(cpu) }; hv_trigger_ipi(coord, IRQ_RESCHEDULE); } #endif /* CHIP_HAS_IPI() */ + +void smp_send_reschedule(int cpu) +{ + WARN_ON(cpu_is_offline(cpu)); + task_isolation_debug(cpu); + __smp_send_reschedule(cpu); +} diff --git a/arch/tile/kernel/unaligned.c b/arch/tile/kernel/unaligned.c index 0db5f7c9d9e5..b1e229a1ff62 100644 --- a/arch/tile/kernel/unaligned.c +++ b/arch/tile/kernel/unaligned.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1545,6 +1546,8 @@ void do_unaligned(struct pt_regs *regs, int vecnum) return; } + task_isolation_check_exception("unaligned JIT at %#lx", regs->pc); + if (!info->unalign_jit_base) { void __user *user_page; diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c index 26734214818c..1dee18d3ffbd 100644 --- a/arch/tile/mm/fault.c +++ b/arch/tile/mm/fault.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -844,6 +845,8 @@ static inline void __do_page_fault(struct pt_regs *regs, int fault_num, void do_page_fault(struct pt_regs *regs, int fault_num, unsigned long address, unsigned long write) { + task_isolation_check_exception("page fault interrupt %d at %#lx (%#lx)", + fault_num, regs->pc, address); __do_page_fault(regs, fault_num, address, write); } diff --git a/arch/tile/mm/homecache.c b/arch/tile/mm/homecache.c index 40ca30a9fee3..e044e8dd8372 100644 --- a/arch/tile/mm/homecache.c +++ b/arch/tile/mm/homecache.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -83,6 +84,7 @@ static void hv_flush_update(const struct cpumask *cache_cpumask, * Don't bother to update atomically; losing a count * here is not that critical. */ + task_isolation_debug_cpumask(&mask); for_each_cpu(cpu, &mask) ++per_cpu(irq_stat, cpu).irq_hv_flush_count; } -- 2.1.2