Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759576AbcDERjp (ORCPT ); Tue, 5 Apr 2016 13:39:45 -0400 Received: from mail-db3on0095.outbound.protection.outlook.com ([157.55.234.95]:3761 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758469AbcDERjk (ORCPT ); Tue, 5 Apr 2016 13:39:40 -0400 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=fail action=none header.from=mellanox.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 v12 11/13] arch/tile: enable task isolation functionality Date: Tue, 5 Apr 2016 13:38:40 -0400 Message-ID: <1459877922-15512-12-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1459877922-15512-1-git-send-email-cmetcalf@mellanox.com> References: <1459877922-15512-1-git-send-email-cmetcalf@mellanox.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:12.216.194.146;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(5003940100001)(189998001)(50986999)(36756003)(33646002)(92566002)(48376002)(586003)(1220700001)(50466002)(107886002)(76176999)(86362001)(85426001)(19580395003)(42186005)(19580405001)(5001770100001)(5001970100001)(50226001)(2950100001)(6806005)(47776003)(2906002)(4326007)(229853001)(106466001)(104016004)(575784001)(5008740100001)(4001430100002)(87936001)(105606002)(11100500001)(1096002)(921003)(83996005)(2101003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR05MB1684;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11OLC003;1:lLtSzf9wtx5K9KNXYhMlRBvH4Vtq+gwZlRP3FblfMsUAL+4NVbLGnM25SDuVu5TqFohctCsMTj3jD/JdKJqmFaMUESNsER+yimxmtj+XPVcKWSxYbGEC8oo2v4HmzGDjjQ1DU8LFWUpdVhdmsJM7laSZ/L2Yx6NX/GBEoGAhSpeUHdME2KKA2lh/q2r5Wet121NZnBnb61P2mtQtyQPEGSd8TO1XvTbeElOTlmfJlQpmQDC2TFDBfJ0zc20JLtdFysLprxkXXIOijHvIaYxBx6U32msBRbcgn+F21zzya7w6LNisGKwLLEAxjdpunrRCVvlAkzFjs3P5pphFNoFYixZT47z/XvtkNtu20gPniYPpHb1vGEbg0JAsu8Fzufkq0gmhBLy1M6zWO+YBRkDzAcTxliIRtP0z+forvH3V4UJhiFp23QXh+Nlz2BSXWOB4ETNR/KWYvYipIbYANu4ADQnxtG7ZQrbhdQQf9mIBJa0HpIbzKD89uyWJYszsFwpLn2E/FBmjjVvUo0QudYAf9ACMxMABGwmsDk+o4YfdgROB7hWJV5gQ0C212gdwRS62kZnukc6g/tiWX5g/3RDdAGt2z4hyaOB2IfpMeXR3kxjU1e8NKJA7K/np9IRzqHe8 MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 2d397832-aac7-4ac5-14a3-08d35d79416a X-Microsoft-Exchange-Diagnostics: 1;AM4PR05MB1684;2:pejgP25loZoTBO/IjnKsPJJLwXgg6E1DAbBV9svv/LSdOtwoYdVZFGdLYRBKKUlHkQ/jS0MQ0d7CErfCdDsd1FODpxyJjFIqdqd+89QpIpnvRr76V9h3cKUt9z8aPnUpicbv5U/EOw8FdRdU8QteMdMZK/56w6ZwbhDib+ep92pMPiDj9//Zb/IihfrOWh93;3:siFqQS0XooXubSABhU480nO71tPk8UB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bp7+hoj69f/fHYyoCi9vGssUHP1R60qg+7Ksw8qP9tXkcXAjQquwNQ2WGXv0uck4nxL38W0fHmro4A3k572ODkKHujehluhry8tPDWZjwPTTZ5TyuPv3C9YehUnywtk43wFGV9c3HkO2wQZ30AJxRN7hRjBUAOR+cGkUBgzk2pVGq2BfoLTQ700JIhTRvu/YpPQVUsMxqg64sQR55PjtYqispi97fm7TK9lsv/XKGG1ZUnMJHH9WH9vshnZ4o2hCX1OaPvolomTHtAK5ub0dhBw+ml0x+v4olMNN+RIun/gg2ZeuFM3zqPfouBI+hZ4TAudeV55fz7p5p2WTj17ysobvTi57Pe8wxwxpJu2NKH5PVBrNExAW81E6dOSgRVEMlhgLx23GecKRNb7DN6hkaaFra6FWXSZ11VNFmrpYEeBIulWPj9nz7A1HaDfyUxOz1OECmV8d5Z65dzKw2Enee8ufQD X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13018025)(13023025)(13024025)(5005006)(13017025)(13015025)(8121501046)(10201501046)(3002001);SRVR:AM4PR05MB1684;BCL:0;PCL:0;RULEID:;SRVR:AM4PR05MB1684; X-Microsoft-Exchange-Diagnostics: 1;AM4PR05MB1684;4:dgCodOE8ZsBgzYeTPerYBvDLJDCtRT0ESjAR/3ie4qU0NbD2HO/4S4QF10I+TNdkSIi8gDiAJQuLFOW12fS8HjWObwAGT+h97DA1YzbGF+oo8Kus6W0ydZ7qY3NuQrMfcCU42MqvC4a3LNRu49przp5/KluXlYQ5f0LXfpigGpVkUqpQUZ9C0CvBffI8HtmfR00+uFSmOgYVUYQ3gVD7tYBPYTVcZuOXlBpG2ZsxDQwuIN9+cFoUreLOHpoyHB8T6oueV5yYKf1V3OZDbyVDZ+AkdCS1t4zcGSpW1Gujf381ujrT7h1Z8X/CePYJFGlAduh3U3tpXRNbNf5sC/Pi6FDPpMLU2BEVllIesDKjKuw9hDw/DVKbW6fwNPD0EiJPKQV3ZqK1tymo/qoQfszBAq+zk6DCsAPfmtxtUIhXhNVswHgVoNUWnheevCGiTlQh1efDns9d/ogRWB+yx6pWqg== X-Forefront-PRVS: 0903DD1D85 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;AM4PR05MB1684;23:l+puPGTfBIjm15dS+b46S/l4E5JkBk+NQRXDJBJgJ?= =?us-ascii?Q?EWKyj6BXrrSqIoz9ePZAt8o/NLFpACxhRdWrm1KgHBZSBTugPFe9ISpKgzoA?= =?us-ascii?Q?51K7sLGTzY6M6LESseICjEGyafXr1qIZ0Jh+CR6+RDbBC6F6x5HBIJhpFVhn?= =?us-ascii?Q?qWki7MxcvEE/1O4JduN3CLnuhYGjpaTeGKKhhUjwKfFvbOjzXktGv71EOkAc?= =?us-ascii?Q?wjf2hYVsAzJ7ZzvL+/Zlt1RpX5lQOIiUaCy26/BCZlQXSPeRw90Q8f2r5nx7?= =?us-ascii?Q?SCH4+S5Fm1vkH7hOsC6QPyU+0w+UArKboIipAK2SQ0KRycTWQFOR4jRI1md1?= =?us-ascii?Q?n3C/7TbyJjBZgME3FmtRuiqXdn/qbCysOLuPX8tBukbA0WWEhU2pDFDwZMIO?= =?us-ascii?Q?hGbu+/F1xIedLY/oJj2mTHPiC0nO6skVjkwjVmgRIg1fvy3efHRqdokLhaYL?= =?us-ascii?Q?ldSDqTlZNgh9ynTR1i5V6eBZxiIl0JgNgh6XOmCCDQZtQs6n3Px0QP4uzHel?= =?us-ascii?Q?P+zIFjzOuXPg/TzCgffKIPkGNQxXeSKr73jy0EfhsNaTPxzIdwJdJVCIrm7A?= =?us-ascii?Q?9xxZA5cJLcGe0g03Su127dnyfO6DCcewQLyVheYOjwGhNJzNJ1fOena5kSA8?= =?us-ascii?Q?lVqbzrHEAgHIVH+h8FKPeMQMI+GaI7BXlnaSEQDuJpEli4DogIcaHtfpFoAB?= =?us-ascii?Q?qSlSbC6itMMPGlcSyc6fiOQlp080jvNt3QEhsjIvYSWGJUpgmdhdSk8/CZel?= =?us-ascii?Q?MWfEpgCx5dQhYryRx24RzMqbZxN3zcSsmowkZ8lx30MHFglvj+WFLh4cXG81?= =?us-ascii?Q?ANsaIgrFwnryAWocV+TQLhEng0ub/qrJL/7o+unFJ1qxjlhTYr6gQarJVvdF?= =?us-ascii?Q?aKLoM8RSQo67wLJV/lln7k04n086Ex52WyAnEnBkGQeEVP+Tg7e3B2kwUbVG?= =?us-ascii?Q?0Y4xw1E4s3hHa1ljZvV1e910nTEg4b1Icemq4MvzB7P2JJ1l0JUD6t02XqLX?= =?us-ascii?Q?WisGVakiGssBybAw5NSIlMXMIjh2LZE8FSoLRUEjZCafNuEyIh8hf3mALf4X?= =?us-ascii?Q?zhMeeGJMMViHEh+Iquk5vlhvWlx3Hf6Vbd+lq56KJ8OZ8PwoxIttZizCL6gs?= =?us-ascii?Q?rFhAC/K3nolOLX5SeD3VPXQutjcHDJOXZS9s0FzRwKj2ljIMZq53E2ybvJxY?= =?us-ascii?Q?RlmTllUh72hr491wOohzZEPb3n2ETVOqUfx?= X-Microsoft-Exchange-Diagnostics: 1;AM4PR05MB1684;5:aXu9KFhuPRclDEkwDwKf/427sXKyPD8Xbwev2w5Xl3+5o6gXT5KqdselIfSyz+giXvrFiOBK4W/u743rpJkL2h73edraQHFZ61vPzzcP04+XW1fxFXLOYVu/fR7c4Bqv+P/lYJRiiXh95Npnr6Ezjg==;24:beB1cT0r8mmEa1Oes5Ci6TL7jMpSZQcQH3l4pg9cxkLMgijXN0eGbA/W3I18CrqVuwfa3cRCatKQbGoQCjZtvQFu0raLBomFwN434qknq1E= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 17:39:35.5058 (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: AM4PR05MB1684 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9281 Lines: 287 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/Kconfig | 1 + arch/tile/include/asm/thread_info.h | 4 +++- arch/tile/kernel/process.c | 9 +++++++++ arch/tile/kernel/ptrace.c | 7 +++++++ 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 ++ 9 files changed, 49 insertions(+), 13 deletions(-) diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 81719302b056..322ba76c8631 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig @@ -33,6 +33,7 @@ config TILE select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select HAVE_ARCH_SECCOMP_FILTER + select HAVE_ARCH_TASK_ISOLATION # FIXME: investigate whether we need/want these options. # select HAVE_IOREMAP_PROT diff --git a/arch/tile/include/asm/thread_info.h b/arch/tile/include/asm/thread_info.h index 4b7cef9e94e0..ea7fbd0d879d 100644 --- a/arch/tile/include/asm/thread_info.h +++ b/arch/tile/include/asm/thread_info.h @@ -126,6 +126,7 @@ extern void _cpu_idle(void); #define TIF_SYSCALL_TRACEPOINT 9 /* syscall tracepoint instrumentation */ #define TIF_POLLING_NRFLAG 10 /* idle is polling for TIF_NEED_RESCHED */ #define TIF_NOHZ 11 /* in adaptive nohz mode */ +#define TIF_TASK_ISOLATION 12 /* in task isolation mode */ #define _TIF_SIGPENDING (1< #include #include +#include #include #include #include @@ -495,9 +496,17 @@ void prepare_exit_to_usermode(struct pt_regs *regs, u32 thread_info_flags) tracehook_notify_resume(regs); } + if (thread_info_flags & _TIF_TASK_ISOLATION) + task_isolation_enter(); + local_irq_disable(); thread_info_flags = READ_ONCE(current_thread_info()->flags); + /* Clear task isolation from cached_flags manually. */ + if ((thread_info_flags & _TIF_TASK_ISOLATION) && + task_isolation_ready()) + thread_info_flags &= ~_TIF_TASK_ISOLATION; + } while (thread_info_flags & _TIF_WORK_MASK); if (thread_info_flags & _TIF_SINGLESTEP) { diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c index 54e7b723db99..475a362415fb 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,12 @@ int do_syscall_trace_enter(struct pt_regs *regs) { u32 work = ACCESS_ONCE(current_thread_info()->flags); + /* In isolation mode, we may prevent the syscall from running. */ + if (work & _TIF_TASK_ISOLATION) { + if (task_isolation_syscall(regs->regs[TREG_SYSCALL_NR]) == -1) + 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..3baa7230149e 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_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_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..754204987532 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_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..7f910e4061f1 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_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.7.2