From patchwork Thu Mar 11 14:23:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12131503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F151C433E0 for ; Thu, 11 Mar 2021 14:25:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D077264FB3 for ; Thu, 11 Mar 2021 14:25:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D077264FB3 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=opbzHY1MAirTs8cHH4JIhwTMq4ubxlK/UqHB5TmRKx4=; b=qAesr/Alh7pyNrwjSSO9QhPD8v JtPXih91cSiW/N8AS9mwiqnUG1GEPC7X/M2L1KTcONkdAEf0VMF/aKjL55nnnRfSB832GSd5XkBK/ mH4HnuQY/ItKRZn9NFJdG3jtoyh58iTdUcD2UUjERkwv0k1UkaN36C5WjRJZ4n3rsXosv5yjFXRyF EHFyrqgtSuVJZw9FG4nGfRWha6k0ICvQgkUc06v4S+HOBG/YgdykBVdy5AcpgrbSyGZBUtNB+cgp+ hXy5sMikG33tT+GZ3UCTGx2+i3ySVU77DQkzAdfSh4lt40zfCRMm4iM+F71Tpf5jtRSukWUqA4DLR 4qB3Y1SQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKMDr-009JuB-2H; Thu, 11 Mar 2021 14:23:31 +0000 Received: from mx2.suse.de ([195.135.220.15]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKMDj-009Jp7-JA for linux-arm-kernel@lists.infradead.org; Thu, 11 Mar 2021 14:23:27 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1615472603; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=po4QZsHAN+vzX5uvzJmshXlPCac7n69c5r9Fdn0dvCo=; b=sjqqOUQpbELgunG51bLYnaAneLdLoAHn6rXcSwK/DsFchfLZJWPal7opKb2RUZtxFSKIEo JbtKBiDJ2iWmLlE8dN17PcQJiP6NCqXX2GAZhWcMmbQgbNa+4/4kethaBp09UxMuCAjwFQ d8u620eAOSyPtbAZDTHxKFPkybBM2LQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DB47BAC23; Thu, 11 Mar 2021 14:23:22 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, clang-built-linux@googlegroups.com Cc: Juergen Gross , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , Deep Shah , "VMware, Inc." , Russell King , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Boris Ostrovsky , Stefano Stabellini , Nathan Chancellor , Nick Desaulniers Subject: [PATCH v7 00/14] x86: major paravirt cleanup Date: Thu, 11 Mar 2021 15:23:05 +0100 Message-Id: <20210311142319.4723-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_142323_897810_5788D6C6 X-CRM114-Status: GOOD ( 16.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is a major cleanup of the paravirt infrastructure aiming at eliminating all custom code patching via paravirt patching. This is achieved by using ALTERNATIVE instead, leading to the ability to give objtool access to the patched in instructions. In order to remove most of the 32-bit special handling from pvops the time related operations are switched to use static_call() instead. At the end of this series all paravirt patching has to do is to replace indirect calls with direct ones. In a further step this could be switched to static_call(), too. Changes in V7: - dropped patch 3, as already applied on tip tree - new patch 3 (patches 1 and 7 have been added to V6 late) - addressed comments by Boris Changes in V6: - switched back to "not" bit in feature value for "not feature" - other minor comments addressed Changes in V5: - patches 1-5 of V4 dropped, as already applied - new patches 1+3 - fixed patch 2 - split V4 patch 8 into patches 4+5 - use flag byte instead of negative feature bit for "not feature" Changes in V4: - fixed several build failures - removed objtool patch, as objtool patches are in tip now - added patch 1 for making usage of static_call easier - even more cleanup Changes in V3: - added patches 7 and 12 - addressed all comments Changes in V2: - added patches 5-12 Juergen Gross (14): x86/alternative: merge include files static_call: move struct static_call_key definition to static_call_types.h static_call: add function to query current function x86/paravirt: switch time pvops functions to use static_call() x86/alternative: support not-feature x86/alternative: support ALTERNATIVE_TERNARY x86/alternative: don't open code ALTERNATIVE_TERNARY() in _static_cpu_has() x86: add new features for paravirt patching x86/paravirt: remove no longer needed 32-bit pvops cruft x86/paravirt: simplify paravirt macros x86/paravirt: switch iret pvops to ALTERNATIVE x86/paravirt: add new macros PVOP_ALT* supporting pvops in ALTERNATIVEs x86/paravirt: switch functions with custom code to ALTERNATIVE x86/paravirt: have only one paravirt patch function arch/arm/include/asm/paravirt.h | 14 +- arch/arm/kernel/paravirt.c | 9 +- arch/arm64/include/asm/paravirt.h | 14 +- arch/arm64/kernel/paravirt.c | 13 +- arch/x86/Kconfig | 1 + arch/x86/entry/entry_32.S | 6 +- arch/x86/entry/entry_64.S | 2 +- arch/x86/entry/vdso/vdso32/system_call.S | 2 +- arch/x86/include/asm/alternative-asm.h | 114 ------------ arch/x86/include/asm/alternative.h | 126 +++++++++++++- arch/x86/include/asm/cpufeature.h | 41 +---- arch/x86/include/asm/cpufeatures.h | 2 + arch/x86/include/asm/irqflags.h | 7 +- arch/x86/include/asm/mshyperv.h | 2 +- arch/x86/include/asm/nospec-branch.h | 1 - arch/x86/include/asm/paravirt.h | 167 ++++++++---------- arch/x86/include/asm/paravirt_types.h | 210 +++++++++-------------- arch/x86/include/asm/smap.h | 5 +- arch/x86/kernel/Makefile | 3 +- arch/x86/kernel/alternative.c | 52 +++++- arch/x86/kernel/asm-offsets.c | 7 - arch/x86/kernel/cpu/vmware.c | 5 +- arch/x86/kernel/kvm.c | 2 +- arch/x86/kernel/kvmclock.c | 2 +- arch/x86/kernel/paravirt-spinlocks.c | 9 + arch/x86/kernel/paravirt.c | 75 ++------ arch/x86/kernel/paravirt_patch.c | 99 ----------- arch/x86/kernel/tsc.c | 3 +- arch/x86/lib/atomic64_386_32.S | 2 +- arch/x86/lib/atomic64_cx8_32.S | 2 +- arch/x86/lib/copy_page_64.S | 2 +- arch/x86/lib/copy_user_64.S | 2 +- arch/x86/lib/memcpy_64.S | 2 +- arch/x86/lib/memmove_64.S | 2 +- arch/x86/lib/memset_64.S | 2 +- arch/x86/lib/retpoline.S | 2 +- arch/x86/xen/enlighten_pv.c | 4 +- arch/x86/xen/time.c | 26 +-- drivers/xen/time.c | 3 +- include/linux/static_call.h | 26 +-- include/linux/static_call_types.h | 18 ++ tools/include/linux/static_call_types.h | 18 ++ 42 files changed, 473 insertions(+), 631 deletions(-) delete mode 100644 arch/x86/include/asm/alternative-asm.h delete mode 100644 arch/x86/kernel/paravirt_patch.c