Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2749863ybh; Mon, 5 Aug 2019 06:15:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxM6ogpk0yjUDEMV/E/Mk5hakSP5io8cM8HDNJMr7xAN+K/og+3z90XkR/nLrcNZ+NFD8am X-Received: by 2002:a17:902:7407:: with SMTP id g7mr145968682pll.214.1565010951596; Mon, 05 Aug 2019 06:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565010951; cv=none; d=google.com; s=arc-20160816; b=xr1FVkYcnkxILjmMsAzsfuIRk9Vc4C7/Mt96EKerL2kdwF5LQZ0LqtsZuA+svM4uf/ mFRmeZM/b+M+igk/DkBJxlnmN+ZdYf1rBbZD+IL4PA26oBHrqKkJhUEq9vOmgnokaU7w a75BIUluCr2rkevKhu7VYPbzFi1sdPPR+yqQTA3yWuTam/ujPaaU3oyxthplK5bj//UP 8ZuvsUG18uKRp+CWQ3V1WQCg1OJNj3nCfit0T/3sAYqOYD7aZRuletP2fOHxTXxllj99 MaouSxZHVs0p34GvYjkPm/hJN2Q5WaetLwjMAp0kjBQt0/KkIgeoiBZUC8UBailyQqpg LD/A== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xY63KD1K/waBQLu8a2Htdl9OHY3LDJuiuQr/nVlomdk=; b=QQu8hSTJ8mEACAakKFIPplyFIcESFeqfPQthk7KGlk9fEwp1ecc9J3qnUWC2OYGd05 lHHNEAs5382OZbCvrynneDQKGrTAnOgBpDoxEA4afcn08FeLQPrflhW768Nd2IsobhI3 CXcpF5rlc9rfz6WepPpS5JnoZcmOmm49ZrnfSltGvlKMKtt8ZGojto74NaXZWrctY6jT LeXxAVV/ndlWDJUN69eqZoD7caidqv1dAFa0BGaDrzMKGcFf8+PdxhL3mj3of23VQyPn PJqYxJHKUmKkdvywDpA0Q53Fdkt3IfGqrotom1Gv49nCYzXhFPJ7dBS3nu5JqGOn8BNf uAhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eZ4iSL2J; 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 i10si47864526pfr.130.2019.08.05.06.15.36; Mon, 05 Aug 2019 06:15:51 -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=@kernel.org header.s=default header.b=eZ4iSL2J; 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 S1729639AbfHENPB (ORCPT + 99 others); Mon, 5 Aug 2019 09:15:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:45104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729316AbfHENHb (ORCPT ); Mon, 5 Aug 2019 09:07:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 E882D216F4; Mon, 5 Aug 2019 13:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010450; bh=ftwEtVmXyEP3joIhCIHtyAXxsY6NzXQywrQe+5/0ptE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eZ4iSL2JKrpRlF8UZQfVhh+Q2hibEQsw1nr2yK2Y6ApW/AIWHOHxh1qwnR4veB2Je LJpS4XPQayyWFx4uLwsgjOUhIKIaw7ns87JAFQzSEnt9gxJW/FqbFVZIWPtFn74uJm 7oq4D0Ow0QB5o93zls8S/aM1U+dAk3NVITDVPudg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhenzhong Duan , Juergen Gross , Boris Ostrovsky , Stefano Stabellini , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Andrew Cooper , Sasha Levin Subject: [PATCH 4.14 28/53] xen/pv: Fix a boot up hang revealed by int3 self test Date: Mon, 5 Aug 2019 15:02:53 +0200 Message-Id: <20190805124931.147684946@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124927.973499541@linuxfoundation.org> References: <20190805124927.973499541@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit b23e5844dfe78a80ba672793187d3f52e4b528d7 ] Commit 7457c0da024b ("x86/alternatives: Add int3_emulate_call() selftest") is used to ensure there is a gap setup in int3 exception stack which could be used for inserting call return address. This gap is missed in XEN PV int3 exception entry path, then below panic triggered: [ 0.772876] general protection fault: 0000 [#1] SMP NOPTI [ 0.772886] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.2.0+ #11 [ 0.772893] RIP: e030:int3_magic+0x0/0x7 [ 0.772905] RSP: 3507:ffffffff82203e98 EFLAGS: 00000246 [ 0.773334] Call Trace: [ 0.773334] alternative_instructions+0x3d/0x12e [ 0.773334] check_bugs+0x7c9/0x887 [ 0.773334] ? __get_locked_pte+0x178/0x1f0 [ 0.773334] start_kernel+0x4ff/0x535 [ 0.773334] ? set_init_arg+0x55/0x55 [ 0.773334] xen_start_kernel+0x571/0x57a For 64bit PV guests, Xen's ABI enters the kernel with using SYSRET, with %rcx/%r11 on the stack. To convert back to "normal" looking exceptions, the xen thunks do 'xen_*: pop %rcx; pop %r11; jmp *'. E.g. Extracting 'xen_pv_trap xenint3' we have: xen_xenint3: pop %rcx; pop %r11; jmp xenint3 As xenint3 and int3 entry code are same except xenint3 doesn't generate a gap, we can fix it by using int3 and drop useless xenint3. Signed-off-by: Zhenzhong Duan Reviewed-by: Juergen Gross Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Andrew Cooper Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin --- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/traps.h | 2 +- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index e09ba4bc8b98f..b2524d349595c 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1113,7 +1113,6 @@ idtentry stack_segment do_stack_segment has_error_code=1 #ifdef CONFIG_XEN idtentry xennmi do_nmi has_error_code=0 idtentry xendebug do_debug has_error_code=0 -idtentry xenint3 do_int3 has_error_code=0 #endif idtentry general_protection do_general_protection has_error_code=1 diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h index afbc87206886e..b771bb3d159bc 100644 --- a/arch/x86/include/asm/traps.h +++ b/arch/x86/include/asm/traps.h @@ -40,7 +40,7 @@ asmlinkage void simd_coprocessor_error(void); asmlinkage void xen_divide_error(void); asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); -asmlinkage void xen_xenint3(void); +asmlinkage void xen_int3(void); asmlinkage void xen_overflow(void); asmlinkage void xen_bounds(void); asmlinkage void xen_invalid_op(void); diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 481d7920ea244..f79a0cdc6b4e7 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -598,12 +598,12 @@ struct trap_array_entry { static struct trap_array_entry trap_array[] = { { debug, xen_xendebug, true }, - { int3, xen_xenint3, true }, { double_fault, xen_double_fault, true }, #ifdef CONFIG_X86_MCE { machine_check, xen_machine_check, true }, #endif { nmi, xen_xennmi, true }, + { int3, xen_int3, false }, { overflow, xen_overflow, false }, #ifdef CONFIG_IA32_EMULATION { entry_INT80_compat, xen_entry_INT80_compat, false }, diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S index 417b339e5c8e1..3a6feed76dfc1 100644 --- a/arch/x86/xen/xen-asm_64.S +++ b/arch/x86/xen/xen-asm_64.S @@ -30,7 +30,6 @@ xen_pv_trap divide_error xen_pv_trap debug xen_pv_trap xendebug xen_pv_trap int3 -xen_pv_trap xenint3 xen_pv_trap xennmi xen_pv_trap overflow xen_pv_trap bounds -- 2.20.1