From owner-svn-src-head@freebsd.org Mon Apr 30 20:18:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09172FB5A3B; Mon, 30 Apr 2018 20:18:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AA41C7B778; Mon, 30 Apr 2018 20:18:32 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A0B6317F86; Mon, 30 Apr 2018 20:18:32 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3UKIWfU006124; Mon, 30 Apr 2018 20:18:32 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3UKIW0n006122; Mon, 30 Apr 2018 20:18:32 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201804302018.w3UKIW0n006122@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 30 Apr 2018 20:18:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333125 - in head/sys/x86: acpica include X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/sys/x86: acpica include X-SVN-Commit-Revision: 333125 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2018 20:18:33 -0000 Author: kib Date: Mon Apr 30 20:18:32 2018 New Revision: 333125 URL: https://svnweb.freebsd.org/changeset/base/333125 Log: Turn off IBRS on suspend. Resume starts CPU from the init state, which clears any loaded microcode updates. As result, IBRS MSRs are no longer available, until the microcode is reloaded. I have to forcibly clear cpu_stdext_feature3, which assumes that CPUID leaf 7 reg %ebx does not report anything except Meltdown/Spectre bugs bits. If future CPUs add new bits there, hw_ibrs_recalculate() and identify_cpu1()/identify_cpu2() need to be adjusted for that. Submitted and tested by: Michael Danilov PR: 227866 Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D15236 Modified: head/sys/x86/acpica/acpi_wakeup.c head/sys/x86/include/x86_var.h Modified: head/sys/x86/acpica/acpi_wakeup.c ============================================================================== --- head/sys/x86/acpica/acpi_wakeup.c Mon Apr 30 19:37:32 2018 (r333124) +++ head/sys/x86/acpica/acpi_wakeup.c Mon Apr 30 20:18:32 2018 (r333125) @@ -209,6 +209,10 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) { ACPI_STATUS status; struct pcb *pcb; +#ifdef __amd64__ + struct pcpu *pc; + int i; +#endif if (sc->acpi_wakeaddr == 0ul) return (-1); /* couldn't alloc wake memory */ @@ -236,6 +240,14 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) if (!CPU_EMPTY(&suspcpus) && suspend_cpus(suspcpus) == 0) { device_printf(sc->acpi_dev, "Failed to suspend APs\n"); return (0); /* couldn't sleep */ + } +#endif +#ifdef __amd64__ + hw_ibrs_active = 0; + cpu_stdext_feature3 = 0; + CPU_FOREACH(i) { + pc = pcpu_find(i); + pc->pc_ibpb_set = 0; } #endif Modified: head/sys/x86/include/x86_var.h ============================================================================== --- head/sys/x86/include/x86_var.h Mon Apr 30 19:37:32 2018 (r333124) +++ head/sys/x86/include/x86_var.h Mon Apr 30 20:18:32 2018 (r333125) @@ -83,7 +83,8 @@ extern int _ugssel; extern int use_xsave; extern uint64_t xsave_mask; extern u_int max_apic_id; -extern int pti; +extern int pti; +extern int hw_ibrs_active; struct pcb; struct thread;