11/*
2- * Copyright (c) 2014, 2022 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2014, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3333import com .oracle .svm .core .SubstrateTargetDescription ;
3434import com .oracle .svm .core .amd64 .AMD64CPUFeatureAccess ;
3535import com .oracle .svm .core .amd64 .AMD64LibCHelper ;
36- import com .oracle .svm .core .feature .InternalFeature ;
3736import com .oracle .svm .core .feature .AutomaticallyRegisteredFeature ;
37+ import com .oracle .svm .core .feature .InternalFeature ;
3838
3939import jdk .vm .ci .amd64 .AMD64 ;
4040
@@ -46,12 +46,25 @@ public class AMD64CPUFeatureAccessFeature extends CPUFeatureAccessFeatureBase im
4646 public void beforeAnalysis (BeforeAnalysisAccess arg ) {
4747 var targetDescription = ImageSingletons .lookup (SubstrateTargetDescription .class );
4848 var arch = (AMD64 ) targetDescription .arch ;
49- var buildtimeCPUFeatures = arch .getFeatures ();
49+ var buildtimeCPUFeatures = filterFeatures ( arch .getFeatures () );
5050 initializeCPUFeatureAccessData (AMD64 .CPUFeature .values (), buildtimeCPUFeatures , AMD64LibCHelper .CPUFeatures .class , (FeatureImpl .BeforeAnalysisAccessImpl ) arg );
5151 }
5252
5353 @ Override
5454 protected AMD64CPUFeatureAccess createCPUFeatureAccessSingleton (EnumSet <?> buildtimeCPUFeatures , int [] offsets , byte [] errorMessageBytes , byte [] buildtimeFeatureMaskBytes ) {
5555 return new AMD64CPUFeatureAccess (buildtimeCPUFeatures , offsets , errorMessageBytes , buildtimeFeatureMaskBytes );
5656 }
57+
58+ /** Returns a copy of {@code features}, with some unwanted features removed. */
59+ private static EnumSet <AMD64 .CPUFeature > filterFeatures (EnumSet <AMD64 .CPUFeature > features ) {
60+ var ret = EnumSet .copyOf (features );
61+ /*
62+ * GR-68707: Intel P-cores and E-cores may differ in the presence of the HT feature. This
63+ * could cause the runtime CPU feature check to fail on hybrid CPUs if an image is built
64+ * with --march=native, the build time checking happens on a P-core, but the runtime
65+ * checking is done on an E-core, even on the same machine.
66+ */
67+ ret .remove (AMD64 .CPUFeature .HT );
68+ return ret ;
69+ }
5770}
0 commit comments