[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-14 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions c,h,cpp -- clang/test/CodeGen/ms-secure-hotpatch-bad-file.c

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-14 Thread via cfe-commits
@@ -250,6 +250,7 @@ add_llvm_component_library(LLVMCodeGen VirtRegMap.cpp WasmEHPrepare.cpp WindowScheduler.cpp + WindowsHotPatch.cpp sivadeilra wrote: Renamed to `WindowsSecureHotPatching.cpp` https://github.com/llvm/llvm-project/pull/138972 _

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-14 Thread via cfe-commits
@@ -0,0 +1,242 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread via cfe-commits
https://github.com/sivadeilra updated https://github.com/llvm/llvm-project/pull/138972 >From 18bcf7a9da1b0698b6e7b9808edf4f12d0db16aa Mon Sep 17 00:00:00 2001 From: Arlie Davis Date: Thu, 3 Apr 2025 16:10:50 -0700 Subject: [PATCH 1/4] Windows hotpatching support Address PR feedback * Simply u

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread via cfe-commits
@@ -807,6 +809,32 @@ void CodeViewDebug::emitObjName() { endSymbolRecord(CompilerEnd); } +void CodeViewDebug::emitHotPatchInformation() { sivadeilra wrote: > Would that tooling remain proprietary, or is it something that will be > open-sourced as well, for

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread via cfe-commits
@@ -0,0 +1,18 @@ +// This verifies that hotpatch function attributes are correctly propagated through LLVM IR when compiling with LTO. +// +// RUN: %clang_cl -c --target=x86_64-windows-msvc -O2 /Z7 -fms-hotpatch-functions-file=%S/ms-hotpatch-functions.txt -flto /Fo%t.bc %s -

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread via cfe-commits
@@ -453,6 +453,37 @@ CodeGenModule::CodeGenModule(ASTContext &C, if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86) getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters", CodeGenOpts.NumRegisterParameters

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -176,6 +176,21 @@ class CallerSym : public SymbolRecord { uint32_t RecordOffset = 0; }; +class HotPatchFuncSym : public SymbolRecord { aganea wrote: Thanks! Would that tooling remain proprietary, or is it something that will be open-sourced as well, for

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -453,6 +453,37 @@ CodeGenModule::CodeGenModule(ASTContext &C, if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86) getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters", CodeGenOpts.NumRegisterParameters

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -0,0 +1,20 @@ +// This verifies that hotpatch function attributes are correctly propagated when compiling directly to OBJ. +// +// RUN: %clang_cl -c --target=x86_64-windows-msvc -O2 /Z7 -fms-hotpatch-functions-file=%S/ms-hotpatch-functions.txt /Fo%t.obj %s ag

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea edited https://github.com/llvm/llvm-project/pull/138972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea edited https://github.com/llvm/llvm-project/pull/138972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -453,6 +453,37 @@ CodeGenModule::CodeGenModule(ASTContext &C, if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86) getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters", CodeGenOpts.NumRegisterParameters

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -0,0 +1,18 @@ +// This verifies that hotpatch function attributes are correctly propagated through LLVM IR when compiling with LTO. +// +// RUN: %clang_cl -c --target=x86_64-windows-msvc -O2 /Z7 -fms-hotpatch-functions-file=%S/ms-hotpatch-functions.txt -flto /Fo%t.bc %s -

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -0,0 +1,242 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -807,6 +809,32 @@ void CodeViewDebug::emitObjName() { endSymbolRecord(CompilerEnd); } +void CodeViewDebug::emitHotPatchInformation() { aganea wrote: As mentionned before, maybe better to rename to `emitSecureHotPatchInformation()` https://github.com/ll

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -250,6 +250,7 @@ add_llvm_component_library(LLVMCodeGen VirtRegMap.cpp WasmEHPrepare.cpp WindowScheduler.cpp + WindowsHotPatch.cpp aganea wrote: Similarily, `WindowsSecureHotPatch.cpp`? https://github.com/llvm/llvm-project/pull/138972 __

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Alexandre Ganea via cfe-commits
@@ -6946,6 +6946,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch); + if (Arg *A = Args.getLastArg(options::OPT_fms_hotpatch_functions_file)) { aganea wrote: Idem, extra brace. https:

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread via cfe-commits
sivadeilra wrote: > We already have /HOTPATCH or rather -fms-hotpatch that does something > different They do something different, but not unrelated. The "Secure Hot-Patching" feature (the feature I'm working on) still relies on the function prolog using hot-patchable code generation. So `/

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread Hans Wennborg via cfe-commits
zmodem wrote: This is very interesting! Initially I also assumed this was about Edit&Continue. As users may have the same idea, I'd suggest adding `DocBrief`s to the new Clang options, and a comment at the top of llvm/lib/CodeGen/WindowsHotPatch.cpp that explain in more detail what they do.

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-13 Thread via cfe-commits
MolecularMatters wrote: > This is very interesting! > > Initially I also assumed this was about Edit&Continue. As users may have the > same idea, I'd suggest adding `DocBrief`s to the new Clang options, and a > comment at the top of llvm/lib/CodeGen/WindowsHotPatch.cpp that explain in > more

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-12 Thread via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-12 Thread via cfe-commits
sivadeilra wrote: > Oh so all this dance (`_ref_` and the additional metadata) is for code page > integrity purposes only? To keep them unmodified in memory? So how does then > the kernel use the PE metadata if it doesn't patch the code memory pages of > the initial (running) image? Is there a

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-12 Thread via cfe-commits
@@ -0,0 +1,20 @@ +// This verifies that hotpatch function attributes are correctly propagated when compiling directly to OBJ. +// +// RUN: %clang_cl -c --target=x86_64-windows-msvc -O2 /Z7 -fms-hotpatch-functions-file=%S/ms-hotpatch-functions.txt /Fo%t.obj %s si

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-12 Thread via cfe-commits
https://github.com/sivadeilra updated https://github.com/llvm/llvm-project/pull/138972 >From 18bcf7a9da1b0698b6e7b9808edf4f12d0db16aa Mon Sep 17 00:00:00 2001 From: Arlie Davis Date: Thu, 3 Apr 2025 16:10:50 -0700 Subject: [PATCH] Windows hotpatching support Address PR feedback * Simply use F

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread Alexandre Ganea via cfe-commits
aganea wrote: Oh so all this dance (`_ref_` and the additional metadata) is for code page integrity purposes? To keep them unmodified in memory? So how does then the kernel use the PE metadata if it doesn't patch the code memory pages of the initial (running) image? Is there an additional mech

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread via cfe-commits
sivadeilra wrote: > I still don't get the _ref_ thing. [...] This is simply how Windows Secure Hotpatching works, and has for years. It relies on different codegen for the hotpatched functions, rather than using fixups to modify code. This way, code segments are not modified (so hashes and

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread via cfe-commits
https://github.com/sivadeilra updated https://github.com/llvm/llvm-project/pull/138972 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,san

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread Alexandre Ganea via cfe-commits
aganea wrote: Thanks for the answer. Are these new flags `-fms-hotpatch-functions-file=` and `-fms-hotpatch-functions-list=` populated with data maintained manually by the Windows developpers? If I understand correctly, what you describe as "symbols that were hot-patched" means functions tha

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread Alexandre Ganea via cfe-commits
@@ -0,0 +1,20 @@ +// This verifies that hotpatch function attributes are correctly propagated when compiling directly to OBJ. +// +// RUN: %clang_cl -c --target=x86_64-windows-msvc -O2 /Z7 -fms-hotpatch-functions-file=%S/ms-hotpatch-functions.txt /Fo%t.obj %s ag

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread via cfe-commits
@@ -0,0 +1,20 @@ +// This verifies that hotpatch function attributes are correctly propagated when compiling directly to OBJ. +// +// RUN: %clang_cl -c --target=x86_64-windows-msvc -O2 /Z7 -fms-hotpatch-functions-file=%S/ms-hotpatch-functions.txt /Fo%t.obj %s si

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread Daniel Paoliello via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread via cfe-commits
@@ -176,6 +176,21 @@ class CallerSym : public SymbolRecord { uint32_t RecordOffset = 0; }; +class HotPatchFuncSym : public SymbolRecord { sivadeilra wrote: Our hot-patch tools read PDBs and then generate metadata that is placed into the final DLL/SYS/EXE,

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread via cfe-commits
https://github.com/sivadeilra edited https://github.com/llvm/llvm-project/pull/138972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread via cfe-commits
https://github.com/sivadeilra updated https://github.com/llvm/llvm-project/pull/138972 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,san

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread via cfe-commits
sivadeilra wrote: > Can you provide a more technical insight about how is this gonna be used? > What are the equivalent MSVC flags? Why is it that users (programmers) need > to select specific functions to hotpatch? This PR is intended to allow LLVM-generated code to work with Windows hot-pat

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread Alexandre Ganea via cfe-commits
@@ -176,6 +176,21 @@ class CallerSym : public SymbolRecord { uint32_t RecordOffset = 0; }; +class HotPatchFuncSym : public SymbolRecord { aganea wrote: Out of curiosity (related to my other questions), historically Windows updates only deliver binaries (DL

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-08 Thread Alexandre Ganea via cfe-commits
aganea wrote: Since the [MSVC flag](https://learn.microsoft.com/en-us/cpp/build/reference/hotpatch-create-hotpatchable-image?view=msvc-170) `/HOTPATCH` has been supported in LLVM and clang-cl for quite a while now (see [this](https://reviews.llvm.org/D116511), and #77245 and #87639) the descr

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread via cfe-commits
https://github.com/sivadeilra updated https://github.com/llvm/llvm-project/pull/138972 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,san

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread via cfe-commits
sivadeilra wrote: For context, here are recent Microsoft announcements concerning hot-patching: * https://www.microsoft.com/en-us/windows-server/blog/2025/04/24/tired-of-all-the-restarts-get-hotpatching-for-windows-server/?msockid=19a6f8f09bd160ac0b18ed449afc614b * https://techcommunity.micros