Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp594260imu; Thu, 22 Nov 2018 02:24:24 -0800 (PST) X-Google-Smtp-Source: AJdET5fzcr5xvQcm6AJj8q1HOBI5SqR7bhOQE7JyqvPjQbAwg3YjGPzsnDMGi/JSPy8V42p5xI1B X-Received: by 2002:a62:a511:: with SMTP id v17-v6mr10783311pfm.18.1542882264578; Thu, 22 Nov 2018 02:24:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542882264; cv=none; d=google.com; s=arc-20160816; b=KzO2aInBAKf3Dx6uixgGUWKec/EiGRVeutpw17FHj5XcSDXA+TeMq6v8pC7YR5i0Qt Y88a8PUhHFus/+MxjbZIjQ5nBlMzc23Za50ki2OtOWrIEZQTsmAQXio6i5lsSdIT6uby kyAHw3r3Juoy4b/ftp8/6WaYc+BHjCYS0Fn4eSeyavB3Bd6YO1DrOjvNGG48uZ8EIs5a QTuSZMRgPSYDBk+4YcOg9P1bKmYghSV3NSRt1M9t29y6xq0FqvLZOjK0qpJtBgUdkiJf Q4CA84eW4RCD0+ukPhIJMJ/FBoak71plU+VZogbWnMg+KZKBec4mJ3rnkTBIkXXrPjFw eLVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=4RG67b7BnkQn+5+ns2i5jl07cWeXmzlhtlQQaNH/jFM=; b=ST/KD3z1LLsBgcHYvVUsYkqEKNLg7BcVANxOCsGh/ugVX+jcxmJm5aWISpAJB1pzJR 6vK5MimQ/q91EKWDcCJXL/i6cEbZ94uEKDSYP8I654o9rTBLJNx9khQLgKlnnVSRfMKY Hnp0z13wz3Kw2E1P8XIgqJQJFtdGRvVeLahiejcK3ZiKzQfaASpUwruaoK/9hBV4/Nt+ u6AyHs3g56WQils983ClpW8qtUiDN0UVqNMByjBech+yHzhH6Dt1wOqfw84euQ1WgHyC tP7cpGyU7kbN94Wdh1iUARyE3Vmp8EVYExt6bFLkg+0vTrm+Uz4139t7kvOI5RMFJr7E CWYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jy7jO3c0; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4-v6si49063625plp.247.2018.11.22.02.24.10; Thu, 22 Nov 2018 02:24:24 -0800 (PST) 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=@kernel.org header.s=default header.b=jy7jO3c0; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390499AbeKVJsE (ORCPT + 99 others); Thu, 22 Nov 2018 04:48:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:38776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390489AbeKVJsC (ORCPT ); Thu, 22 Nov 2018 04:48:02 -0500 Received: from localhost (c-71-205-112-160.hsd1.co.comcast.net [71.205.112.160]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D413D20870; Wed, 21 Nov 2018 23:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542841893; bh=5uzy4AP48hkewUCs85Xy/7AJYLLCllybvIaEASouOoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=jy7jO3c0Z528KEq9TLAXYRJTODQnm3bBF1bxe7CqdxeMXPKl9oWynT1/PJb8Wruel 2JOhlx6zPQerHPep1+9+mgqp9fugxbBvHccEua5IIzvmIJlhKv0cc4PGZvV+jXZh+v BgcYyeOOb5dq1IhvgLozHB92XlbBQx2C76Brb4Qo= From: Andy Lutomirski To: x86@kernel.org Cc: LKML , Yu-cheng Yu , Dave Hansen , Peter Zijlstra , Borislav Petkov , Andy Lutomirski Subject: [PATCH v2 3/5] x86/oops: Show the correct CS value in show_regs() Date: Wed, 21 Nov 2018 15:11:24 -0800 Message-Id: <4e36812b6e1e95236a812021d35cbf22746b5af6.1542841400.git.luto@kernel.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org show_regs() shows the CS in the CPU register instead of the value in regs. This means that we'll probably print "CS: 0010" almost all the time regardless of what was actually in CS when the kernel malfunctioned. This gives a particularly confusing result if we OOPSed due to an implicit supervisor access from user mode. Signed-off-by: Andy Lutomirski --- arch/x86/kernel/process_64.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 0e0b4288a4b2..2b8e6324fa20 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -66,7 +66,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode) unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs; unsigned long d0, d1, d2, d3, d6, d7; unsigned int fsindex, gsindex; - unsigned int ds, cs, es; + unsigned int ds, es; show_iret_regs(regs); @@ -98,7 +98,6 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode) } asm("movl %%ds,%0" : "=r" (ds)); - asm("movl %%cs,%0" : "=r" (cs)); asm("movl %%es,%0" : "=r" (es)); asm("movl %%fs,%0" : "=r" (fsindex)); asm("movl %%gs,%0" : "=r" (gsindex)); @@ -114,7 +113,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode) printk(KERN_DEFAULT "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n", fs, fsindex, gs, gsindex, shadowgs); - printk(KERN_DEFAULT "CS: %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds, + printk(KERN_DEFAULT "CS: %04lx DS: %04x ES: %04x CR0: %016lx\n", regs->cs, ds, es, cr0); printk(KERN_DEFAULT "CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3, cr4); -- 2.17.2