Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4097608imm; Mon, 15 Oct 2018 09:04:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV622MjTpGk6k/M7gGlpg/gXkKtnIf5cl+DtRfw1C80oMopqz5++755oTIXchYqZHl/5WeztX X-Received: by 2002:a62:5982:: with SMTP id k2-v6mr17760345pfj.180.1539619486242; Mon, 15 Oct 2018 09:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539619486; cv=none; d=google.com; s=arc-20160816; b=wXiMzaKaHUZcd/MNdUbnd1VeeG7yo7bVfVhzvoddvn50e/nVVEJs2TLt6xWSAK4IFa g7ICQS3S9TbCc0RvqTJvmUP5wGLZogeitCG3+Hq3x2BkJ+ODc0emh/3X71X6fK+jwm0g pXPkW6+aAbY0tUZ4J8gPjhDB04yWEl1pJUQHfkdS7jNgIJ5JP8odMvt2/4RS8RN+G52K 7IxN4sYXnmDWE6BqLe3oC9LBk8gyJyrZdghwMbrftpU1hxcA1+F9QPW3IhlQLrLyK0Wq RYk+dW/WiEHzCu2cJhcDvS4gcnYDJwVDyxRbhpCR6U23bXH3yPexmQucyuYju8uUrC82 mubg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oQgMQdrQGzXtmSBk07HhUnic5I/7MhYtrGTZQul9tJA=; b=0fo5/xvw9E7ByI3kRcTiXxXgim2Cqz/XMERj7FYTFWMpZow1m/c29hnw55IXSDsfoj pMxU5h47Vl/YzPFrgJThF35tXlX8MnwMrdFv/Dw+GyBq9g6l+fhI4XkGIjBmHjLXOU08 ozwDmGtDNaDovFDDWFd1exjHdujeOf1z54qBh0sb1FvF6jGvW4ylmi92QV3gB1xhL0yh D34ZbvIWfCCfxs0iCY5xthgDNVLAzLuAJtQ/ciYvvx/CTuW2P9to7hGtcfb2mCTSBBFm n3PHLs+EeBjmtUPnPriMQtWq1iAifxDZfinJliabd9dNpVheVuikenwFjMHcjVWGJgMA dN2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=LDQPbA9l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i72-v6si11121421pfe.224.2018.10.15.09.04.30; Mon, 15 Oct 2018 09:04:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=LDQPbA9l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726707AbeJOXtp (ORCPT + 99 others); Mon, 15 Oct 2018 19:49:45 -0400 Received: from mail-wm1-f53.google.com ([209.85.128.53]:52706 "EHLO mail-wm1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbeJOXto (ORCPT ); Mon, 15 Oct 2018 19:49:44 -0400 Received: by mail-wm1-f53.google.com with SMTP id 189-v6so19485784wmw.2 for ; Mon, 15 Oct 2018 09:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=oQgMQdrQGzXtmSBk07HhUnic5I/7MhYtrGTZQul9tJA=; b=LDQPbA9lG9xaCGb5wQcAh2HBFRVRv7CSW1MbPMCQ88NSSD4ZogrS/dEn1U5H2bq6o9 dPa2/5CULgdfV5AkyHEVcVgLHigzAAkDI1/mYM/sraQBMP7Z/7aMsbdYHWta+XPrQ/CY AftWJSaj+HbGxmFlGi9Jn0fh0jhQipALjB/SrBizW/uull5206Sjj47p/+5t4Ja3eO1Z TSm9ZhD2qoL7SxgvwT5GIkW/zLnTFXHARfXsx3/SVGv6Xg0/b3u89JXGBGzyaZlI7PdG W1G16yvpu2k48kHJGwiVxe1sVzktual7JUJYukSbR9i6MIPRavUxs9A7/0Ku9hv/JPni miYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oQgMQdrQGzXtmSBk07HhUnic5I/7MhYtrGTZQul9tJA=; b=tx6cjbkIXhH6QkofGZYLAgryC+9PP07R1kd848XH9neps3v4WegevulwS5FhI7CXmQ i5wgYnJch0CMNArqh/SB+F4q5hm05sLOKc7R75LGWN69UA+2kLwSZIURTTirUpVoEPrg kvBB/TCePpjy5VWt1ONVPI6e6NXW6rNIN78FHCrEBURRSiRK9r2ytBwFKTT/IHIZK24Z /FaeOglkorqwDYcb584bAQ2SKCr0K+wganTQXCQ5S7yMQWzGeeaR/YYY+xMfgP57XLBv YRjWW75lZ7BFFEwd2yk+7uyjk3QEcY94jmK/CXYALOBZw1TjbUwNtOcACXNSV0OaO3jx fyQA== X-Gm-Message-State: ABuFfoh0aPJ2d0X+dqr7T27pL8RbuCg/6vAQvhoE8+JUGUSV0XE2xMxG 1hwvbhK+1Q6g7iyRJNxKG4FPITuvwEAFKS2zK5o1gQ== X-Received: by 2002:a1c:9355:: with SMTP id v82-v6mr13408872wmd.128.1539619431716; Mon, 15 Oct 2018 09:03:51 -0700 (PDT) MIME-Version: 1.0 References: <20181015003726.29103-1-nick.desaulniers@gmail.com> <20181015051705.GA20687@flashbox> <2CCAF5D3-1B11-43BF-93E4-72C2603A184F@amacapital.net> <20181015152221.GA16375@flashbox> <20181015153144.buuow3yof2njjzjm@treble> In-Reply-To: <20181015153144.buuow3yof2njjzjm@treble> From: Andy Lutomirski Date: Mon, 15 Oct 2018 09:03:40 -0700 Message-ID: Subject: Re: [PATCH] x86/mm: annotate no_context with UNWIND_HINTS To: Josh Poimboeuf Cc: natechancellor@gmail.com, Andrew Lutomirski , nick.desaulniers@gmail.com, Dave Hansen , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , X86 ML , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 15, 2018 at 8:31 AM Josh Poimboeuf wrote: > > On Mon, Oct 15, 2018 at 08:22:21AM -0700, Nathan Chancellor wrote: > > > >>> @@ -760,9 +760,11 @@ no_context(struct pt_regs *regs, unsigned lo= ng error_code, > > > >>> * and then double-fault, though, because we're li= kely to > > > >>> * break the console driver and lose most of the s= tack dump. > > > >>> */ > > > >>> - asm volatile ("movq %[stack], %%rsp\n\t" > > > >>> + asm volatile (UNWIND_HINT_SAVE > > > >>> + "movq %[stack], %%rsp\n\t" > > > >>> "call handle_stack_overflow\n\t" > > > >>> - "1: jmp 1b" > > > >>> + "1: jmp 1b\n\t" > > > >>> + UNWIND_HINT_RESTORE > > > >>> : ASM_CALL_CONSTRAINT > > > >>> : "D" ("kernel stack overflow (page = fault)"), > > > >>> "S" (regs), "d" (address), > > > >> > > > >> NAK. Just below this snippet is unreachable(); > > > >> > > > >> Can you reply with objtool -dr output on a problematic fault.o? J= osh, > > > >> it *looks* like annotate_unreachable() should be doing the right > > > >> thing, but something is clearly busted. > > > >> > > > >> Also, shouldn't compiler-clang.h contain a reasonable definition o= f > > > >> unreachable()? > > > >> > > > >> --Andy > > > > > > > > Hi Andy, > > > > > > > > Did you mean 'objdump -dr'? If so, here you go (rather long, sorry = if I > > > > should have pasted it here instead): > > > > https://gist.github.com/nathanchance/f038bb0a6653b975bb8a4e64fcd550= 3e > > > > > > > > > > > > > > Hmm, -dr wasn=E2=80=99t quite enough to dump the .discard bits, assum= ing they=E2=80=99re there at all. Can you just put the whole .o file somewh= ere? > > > > Here you go: https://nathanchance.me/downloads/.tmp/fault.o > > $ eu-readelf -S /tmp/fault.o |grep reachable > [12] .discard.reachable PROGBITS 0000000000000000 00002bc0 00000014= 0 0 0 1 > [13] .rela.discard.reachable RELA 0000000000000000 00002bd8 00000= 078 24 I 32 12 8 > > That confirms that you need a clang version of the unreachable() macro. > Duh. That being said, the generic macro is: # define unreachable() do { annotate_reachable(); do { } while (1); } while= (0) I'm probably missing some subtlety here, but shouldn't that be annotate_*un*reachable()? Of course, there are any number of reasons why there should be a real definition. Nathan and Nick, does adding something like: #define unreachable() \ do { \ annotate_unreachable(); \ __builtin_unreachable(); \ } while (0) to compiler-clang.h fix the problem? --Andy