=== Applying patches on top of PostgreSQL commit ID aecc558666ad62fbecb08ff7af1394656811a581 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sun Mar 1 00:30:28 UTC 2026 On branch cf/6496 nothing to commit, working tree clean === using 'git am' to apply patch ./v6-0002-Centralize-detection-of-x86-CPU-features.patch === Applying: Centralize detection of x86 CPU features Using index info to reconstruct a base tree... M src/port/pg_cpu_x86.c M src/port/pg_crc32c_sse42.c M src/port/pg_popcount_x86.c M src/tools/pgindent/typedefs.list Falling back to patching base and 3-way merge... Auto-merging src/tools/pgindent/typedefs.list Auto-merging src/port/pg_cpu_x86.c CONFLICT (content): Merge conflict in src/port/pg_cpu_x86.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Centralize detection of x86 CPU features When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". Unstaged changes after reset: M src/port/pg_cpu_x86.c === using patch(1) to apply patch ./v6-0002-Centralize-detection-of-x86-CPU-features.patch === The next patch would create the file src/include/port/pg_cpu.h, which already exists! Skipping patch. 1 out of 1 hunk ignored patching file src/port/pg_cpu_x86.c Hunk #1 FAILED at 1. Hunk #2 FAILED at 34. Hunk #3 FAILED at 58. Hunk #4 FAILED at 82. 4 out of 4 hunks FAILED -- saving rejects to file src/port/pg_cpu_x86.c.rej patching file src/port/pg_crc32c_sse42.c Hunk #1 FAILED at 19. Hunk #2 FAILED at 158. 2 out of 2 hunks FAILED -- saving rejects to file src/port/pg_crc32c_sse42.c.rej patching file src/port/pg_popcount_x86.c Hunk #1 FAILED at 14. Hunk #2 FAILED at 58. Hunk #3 FAILED at 143. Hunk #4 FAILED at 159. 4 out of 4 hunks FAILED -- saving rejects to file src/port/pg_popcount_x86.c.rej patching file src/tools/pgindent/typedefs.list Hunk #1 FAILED at 3394. 1 out of 1 hunk FAILED -- saving rejects to file src/tools/pgindent/typedefs.list.rej Removing src/port/pg_cpu_x86.c.rej Removing src/port/pg_crc32c_sse42.c.rej Removing src/port/pg_popcount_x86.c.rej Removing src/tools/pgindent/typedefs.list.rej === using 'git apply' to apply patch ./v6-0002-Centralize-detection-of-x86-CPU-features.patch === Performing three-way merge... Applied patch to 'src/include/port/pg_cpu.h' cleanly. Applied patch to 'src/port/pg_cpu_x86.c' with conflicts. Applied patch to 'src/port/pg_crc32c_sse42.c' cleanly. Applied patch to 'src/port/pg_popcount_x86.c' cleanly. Applied patch to 'src/tools/pgindent/typedefs.list' cleanly. U src/port/pg_cpu_x86.c diff --cc src/port/pg_cpu_x86.c index 7575838245c,88863f9762c..00000000000 --- a/src/port/pg_cpu_x86.c +++ b/src/port/pg_cpu_x86.c @@@ -30,35 -30,33 +30,45 @@@ #endif #include "port/pg_cpu.h" ++<<<<<<< ours ++======= + + + /* array indexed by enum X86FeatureId */ + bool X86Features[X86FeaturesSize] = {0}; ++>>>>>>> theirs /* - * Does XGETBV say the ZMM registers are enabled? + * XSAVE state component bits that we need * - * NB: Caller is responsible for verifying that osxsave is available - * before calling this. + * https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-1-manual.pdf + * Chapter "MANAGING STATE USING THE XSAVE FEATURE SET" */ -#ifdef HAVE_XSAVE_INTRINSICS -pg_attribute_target("xsave") -#endif +#define XMM (1<<1) +#define YMM (1<<2) +#define OPMASK (1<<5) +#define ZMM0_15 (1<<6) +#define ZMM16_31 (1<<7) + + +/* array indexed by enum X86FeatureId */ +bool X86Features[X86FeaturesSize] = {0}; + static bool -zmm_regs_available(void) +mask_available(uint32 value, uint32 mask) { -#ifdef HAVE_XSAVE_INTRINSICS - return (_xgetbv(0) & 0xe6) == 0xe6; -#else - return false; -#endif + return (value & mask) == mask; } /* * Parse the CPU ID info for runtime checks. */ ++<<<<<<< ours +#ifdef HAVE_XSAVE_INTRINSICS +pg_attribute_target("xsave") +#endif ++======= ++>>>>>>> theirs void set_x86_features(void) { @@@ -74,12 -72,10 +84,19 @@@ X86Features[PG_SSE4_2] = exx[2] >> 20 & 1; X86Features[PG_POPCNT] = exx[2] >> 23 & 1; ++<<<<<<< ours /* All these features depend on OSXSAVE */ if (exx[2] & (1 << 27)) { + uint32 xcr0_val = 0; + ++======= ++ ++ /* All these features depend on OSXSAVE */ ++ if (exx[2] & (1 << 27)) ++ { ++>>>>>>> theirs /* second cpuid call on leaf 7 to check extended AVX-512 support */ memset(exx, 0, 4 * sizeof(exx[0])); @@@ -90,14 -86,7 +107,18 @@@ __cpuidex(exx, 7, 0); #endif ++<<<<<<< ours +#ifdef HAVE_XSAVE_INTRINSICS + /* get value of Extended Control Register */ + xcr0_val = _xgetbv(0); +#endif + + /* Are ZMM registers enabled? */ + if (mask_available(xcr0_val, XMM | YMM | + OPMASK | ZMM0_15 | ZMM16_31)) ++======= + if (zmm_regs_available()) ++>>>>>>> theirs { X86Features[PG_AVX512_BW] = exx[1] >> 30 & 1; X86Features[PG_AVX512_VL] = exx[1] >> 31 & 1;