Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4156445imm; Mon, 15 Oct 2018 09:58:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV63kTgF09UpClDFuqvvgOqSuTFv47Y56Hz4A8dKSRyF9gxZUpfmEpcsjPtx0v3GoLrlJ2FPc X-Received: by 2002:a62:8a4f:: with SMTP id y76-v6mr18504360pfd.142.1539622707715; Mon, 15 Oct 2018 09:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539622707; cv=none; d=google.com; s=arc-20160816; b=ZObN885IPPFvLdQC5mmgMC4kyEQefWAms8atUCMp4A4gFFmjNpIhVhdjxUmnnF/uix 6SUrdxRFsUJ/ZYlsl0jxzi9MiRqcO8fXDU+AclwLxbmsYVQKRLzYW2pOlil/ZvhcYe7y F/KXrAwi/dqaRR2SbDBUnE8Pc2cqHUGce8swCeyaE84sBepgH7QGU5ozx25LVwRMB1VW q0aooNH2jXmJW7oJaAEv8nhK0gvQlPg3LwjLLz2XCkldHztJAneU1XLz4o+QGRjHUnNU 9NdLzfyGAoO82o22MNLqhlcG4iPWNqalGaWB9gRJFqoE5AckBlnLkf24X+s5iSaoNRee lyCA== 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=U15UCWqeHrXpD32qORNBO3YAafTTCD25I7l7dRG+9Kw=; b=xk6PDa018omuizeCGLAgfNUyOiyYSKKETbiZNWNOZbALyE4IrL4un0pBAxOkeLRymM 7voNO6fllUYX2mQTBztWOL/d4DXXrhM4dR9j9TteU4oTivviOxBeaLY3QcZMbwf86hfs N9JeQc7fgkMT4nVZh/Esq80dnD82uZyQW33e33zuHRv9H+nveUx3BKgMghWyn7biWVXi 4MP7U47SzgLWSFLSDny85BihO/ZKVyenDnz5P5DYiJqo+Z6YRKtUOf7hWBmVC0XBzx2u Qiae5H0eX1I+8/GNP9ma5CGULiqOu7lynkVdWhVPbKgkKjm3+uj+6+B0KPNQek9gHgsw /qEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rd7QEylc; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j13-v6si10612141pfn.288.2018.10.15.09.58.12; Mon, 15 Oct 2018 09:58:27 -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=@gmail.com header.s=20161025 header.b=rd7QEylc; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbeJPAnb (ORCPT + 99 others); Mon, 15 Oct 2018 20:43:31 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:46499 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726557AbeJPAnb (ORCPT ); Mon, 15 Oct 2018 20:43:31 -0400 Received: by mail-oi1-f195.google.com with SMTP id k64-v6so15616526oia.13 for ; Mon, 15 Oct 2018 09:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=U15UCWqeHrXpD32qORNBO3YAafTTCD25I7l7dRG+9Kw=; b=rd7QEylceDOP38EQkHleqnfZghKqxc1KIcOKw7vev+zEbd4lwSX3TpSnaEA8TKmQSD F7KxvJ0HHbuEcs4SZ2IxqLX//aQNXMQed1ezCZpibOHXqoM8PLF8N07dPelqxTcNwGk1 d954XW9mnZ9ualKzn8v8/S19GxbBEIPZgVacCpLOn/ma4oJY1EUxRDKkqqSZVtPRTCx+ KZ/zGMhMyIvj9ryjU9p3Oiv85kCdeRlhVSdTRnBeeIgJ5TnU+HJFawqS3k1czz3maACw NuuLvDLKAyw+2tx4zM2+4DybiJmHBO2M7ZUHV9vXdZDUFm409mdqRdQctdI8wqQeJTTA sTXg== 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=U15UCWqeHrXpD32qORNBO3YAafTTCD25I7l7dRG+9Kw=; b=MIGSKpvOdvXYqy9kVnt83zuNGCbgX0c/NtK/glHxkKQqsQ21zfVLEgyYUu+JuNBw5c 9HgWK2QLhZya1yIy8V9NGl3Xha761B6wql8bE3Wa669NqfRiOlPbO25JkHzZwBiQ4cBa LzxV5z2rfg/2j93OAfNeCaJgjApAu/aeZ9XoWsDT5zWrchzUJRuhTWojiR6bZlvyYeFH hcxCeZBIGfGyZ6zE6qwZX5IdbdQkds4BEV3eUwOcEs0BnexUSGnRwlUiPq7tXJ5m06gp dR1ggaeAss5Th51ERS9dqJoTInbIHkr0XLBkSGbn9XIOBaVL0qW3qMU3tqvYJy/EBd1+ xl4g== X-Gm-Message-State: ABuFfohxUtf41nx9RSZcpXxx6JN43pcsvze7BhDZNoTK1DAtZewWBVYp 22JVTs+vyTtB2letY/646IuDN6O2F8z7MZx0eaU= X-Received: by 2002:aca:6b45:: with SMTP id g66-v6mr10103273oic.273.1539622647971; Mon, 15 Oct 2018 09:57:27 -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: From: Nick Desaulniers Date: Mon, 15 Oct 2018 09:57:16 -0700 Message-ID: Subject: Re: [PATCH] x86/mm: annotate no_context with UNWIND_HINTS To: luto@amacapital.net Cc: Josh Poimboeuf , Nathan Chancellor , luto@kernel.org, dave.hansen@linux.intel.com, Peter Zijlstra , Thomas Gleixner , Ingo Molnar , bp@alien8.de, "H. Peter Anvin" , x86@kernel.org, Linux Kernel Mailing List 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 9:03 AM Andy Lutomirski wrote= : > > On Mon, Oct 15, 2018 at 8:31 AM Josh Poimboeuf wrot= e: > > > > On Mon, Oct 15, 2018 at 08:22:21AM -0700, Nathan Chancellor wrote: > > > > >>> @@ -760,9 +760,11 @@ no_context(struct pt_regs *regs, unsigned = long error_code, > > > > >>> * and then double-fault, though, because we're = likely to > > > > >>> * break the console driver and lose most of the= stack 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 (pag= e fault)"), > > > > >>> "S" (regs), "d" (address), > > > > >> > > > > >> NAK. Just below this snippet is unreachable(); > > > > >> > > > > >> Can you reply with objtool -dr output on a problematic fault.o? = Josh, > > > > >> 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= of > > > > >> unreachable()? > > > > >> > > > > >> --Andy > > > > > > > > > > Hi Andy, > > > > > > > > > > Did you mean 'objdump -dr'? If so, here you go (rather long, sorr= y if I > > > > > should have pasted it here instead): > > > > > https://gist.github.com/nathanchance/f038bb0a6653b975bb8a4e64fcd5= 503e > > > > > > > > > > > > > > > > > > Hmm, -dr wasn=E2=80=99t quite enough to dump the .discard bits, ass= uming they=E2=80=99re there at all. Can you just put the whole .o file some= where? > > > > > > Here you go: https://nathanchance.me/downloads/.tmp/fault.o > > > > $ eu-readelf -S /tmp/fault.o |grep reachable > > [12] .discard.reachable PROGBITS 0000000000000000 00002bc0 000000= 14 0 0 0 1 > > [13] .rela.discard.reachable RELA 0000000000000000 00002bd8 000= 00078 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); } whi= le (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? I broke this myself in commit 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive"). Thanks for the suggestion, will verify then send a patch with your suggested by tag. Thanks everyone for helping us sort this out!