Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3998427yba; Mon, 29 Apr 2019 12:00:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwngU2NuoWKe95RyGanVk3OzR4hXxPF/VYHmxl8YLaY4DBhvrrDrwxzDab7ptvrvPgpTAgN X-Received: by 2002:a62:544:: with SMTP id 65mr25943373pff.46.1556564409500; Mon, 29 Apr 2019 12:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556564409; cv=none; d=google.com; s=arc-20160816; b=sO9puGq+3lEEOgEK2mUCg+oBflIVgYeyyzOL1XF3Tv8E7u9lT3+7M8lZ/+KW0+lHlu 7uYU2DhykI7AZudjEYSJQCBlsBzjZYUROhHD0P+0KImenraqZqFruFBf3c0Tq90MaDk6 bOKFUvhmfDx01gG9ElxY3rTz1uHUlJDyKDuW+VhoawZqzklYALEGWt0yZf7Bxg6UVv46 CuobSyQNr9dtqKzPiMErOefMng5ocIOXGOcZsAG5dXypF/qseZQ7oGBvOPrIsQXU2m+/ eguRgzmlzBIbsBbAYQdSgsGsbPiV+PcT+2v9KGyuxovsI3KjY1gMEfeMbDUCbQ9VO56S JuBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PsMtaskjlqfTorX+CgQLAww8FEYIqX9tYc8xmkXa/bI=; b=w8PrETFn96w4kwVQCi1m/vB5fpz1gicQjecdR7m7Z6jK/HY8g/fCEUrRK2Un6SNUVP SnqaOcPuRpfHupHEXoLeQNvoNQ2QA5vrPUY7lC8VNq+BU3/8FgJQljFRceVZupTlMpA5 Avoys89VnmuX2YUpDwZhgQfzPLuRoFakNJxwxPojG0kdq3nroSf60mZfKDgkypE5RWXp 8/1Zcu2E8trtRavaere40dmZLqKXRmdwSzJIh0EhrWKiUV5PXc3N46Qn4tgyj3JsFcE5 Cxl4f0ethK0AjCBWcOZXE5qmxdc6GmR5NcO+FTKEmIeM2vuaf1ZhOYiyP5gpODn6Af5D 6eSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ao1BVcNP; 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 s19si8618676plr.216.2019.04.29.11.59.52; Mon, 29 Apr 2019 12:00:09 -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=Ao1BVcNP; 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 S1729167AbfD2S5K (ORCPT + 99 others); Mon, 29 Apr 2019 14:57:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:52700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728962AbfD2S5K (ORCPT ); Mon, 29 Apr 2019 14:57:10 -0400 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F10E8217D7 for ; Mon, 29 Apr 2019 18:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556564229; bh=ZDqmipFipLpIZw5XbwEeviScDby2c6433f2grnTYDCA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ao1BVcNPwNf0yh8qnDaggwfnP8lN4iW+WoY3L+qCIRO2F8n/zMqxfRWEz5SnoYr8K lnoQVz8nIstYY3gLTItaPJB8Z5GkZGnI8coN5Le1pOM9Nnv2IGeHXAg+N6lyuYVg2G xyBZ/oX/5sX1A8bkBDTseC3+IvRNBWHyKCng/NZ8= Received: by mail-wm1-f45.google.com with SMTP id h18so640073wml.1 for ; Mon, 29 Apr 2019 11:57:08 -0700 (PDT) X-Gm-Message-State: APjAAAU1YOcg5kHMKe7+UZoQw0L6zZXWMPAmV4WQrjheRnjyJIliylYd y9zGechmSAA6od4FqhvEshwi67yQUU6qusdnn7i+eQ== X-Received: by 2002:a7b:c257:: with SMTP id b23mr344247wmj.83.1556564225766; Mon, 29 Apr 2019 11:57:05 -0700 (PDT) MIME-Version: 1.0 References: <20190427100639.15074-1-nstange@suse.de> <20190427100639.15074-4-nstange@suse.de> <20190427102657.GF2623@hirez.programming.kicks-ass.net> <20190428133826.3e142cfd@oasis.local.home> In-Reply-To: From: Andy Lutomirski Date: Mon, 29 Apr 2019 11:56:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/4] x86/ftrace: make ftrace_int3_handler() not to skip fops invocation To: Linus Torvalds Cc: Andrew Lutomirski , Steven Rostedt , Peter Zijlstra , Nicolai Stange , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "the arch/x86 maintainers" , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan , Konrad Rzeszutek Wilk , Tim Chen , Sebastian Andrzej Siewior , Mimi Zohar , Juergen Gross , Nick Desaulniers , Nayna Jain , Masahiro Yamada , Joerg Roedel , Linux List Kernel Mailing , live-patching@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 29, 2019 at 11:53 AM Linus Torvalds wrote: > > > > On Mon, Apr 29, 2019, 11:42 Andy Lutomirski wrote: >> >> >> I'm less than 100% convinced about this argument. Sure, an NMI right >> there won't cause a problem. But an NMI followed by an interrupt will >> kill us if preemption is on. I can think of three solutions: > > > No, because either the sti shadow disables nmi too (that's the case on some CPUs at least) or the iret from nmi does. > > Otherwise you could never trust the whole sti shadow thing - and it very much is part of the architecture. > Is this documented somewhere? And do you actually believe that this is true under KVM, Hyper-V, etc? As I recall, Andrew Cooper dug in to the way that VMX dealt with this stuff and concluded that the SDM was blatantly wrong in many cases, which leads me to believe that Xen HVM/PVH is the *only* hypervisor that gets it right. Steven's point about batched updates is quite valid, though. My personal favorite solution to this whole mess is to rework the whole thing so that the int3 handler simply returns and retries and to replace the sync_core() broadcast with an SMI broadcast. I don't know whether this will actually work on real CPUs and on VMs and whether it's going to crash various BIOSes out there.