mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	Introduce an AWK script to auto-generate the <asm/cpufeaturemasks.h> header with required and disabled feature masks based on <asm/cpufeatures.h> and the current build config. Thus for any CPU feature with a build config, e.g., X86_FRED, simply add: config X86_DISABLED_FEATURE_FRED def_bool y depends on !X86_FRED to arch/x86/Kconfig.cpufeatures, instead of adding a conditional CPU feature disable flag, e.g., DISABLE_FRED. Lastly, the generated required and disabled feature masks will be added to their corresponding feature masks for this particular compile-time configuration. [ Xin: build integration improvements ] [ mingo: Improved changelog and comments ] Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Signed-off-by: Xin Li (Intel) <xin@zytor.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20250305184725.3341760-3-xin@zytor.com
		
			
				
	
	
		
			49 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
// SPDX-License-Identifier: GPL-2.0-or-later
 | 
						|
/* ----------------------------------------------------------------------- *
 | 
						|
 *
 | 
						|
 *   Copyright 2008 rPath, Inc. - All Rights Reserved
 | 
						|
 *
 | 
						|
 * ----------------------------------------------------------------------- */
 | 
						|
 | 
						|
/*
 | 
						|
 * This is a host program to preprocess the CPU strings into a
 | 
						|
 * compact format suitable for the setup code.
 | 
						|
 */
 | 
						|
 | 
						|
#include <stdio.h>
 | 
						|
 | 
						|
#include "../include/asm/cpufeatures.h"
 | 
						|
#include "../include/asm/vmxfeatures.h"
 | 
						|
#include "../kernel/cpu/capflags.c"
 | 
						|
 | 
						|
int main(void)
 | 
						|
{
 | 
						|
	int i, j;
 | 
						|
	const char *str;
 | 
						|
 | 
						|
	printf("#include <asm/cpufeaturemasks.h>\n\n");
 | 
						|
	printf("static const char x86_cap_strs[] =\n");
 | 
						|
 | 
						|
	for (i = 0; i < NCAPINTS; i++) {
 | 
						|
		for (j = 0; j < 32; j++) {
 | 
						|
			str = x86_cap_flags[i*32+j];
 | 
						|
 | 
						|
			if (i == NCAPINTS-1 && j == 31) {
 | 
						|
				/* The last entry must be unconditional; this
 | 
						|
				   also consumes the compiler-added null
 | 
						|
				   character */
 | 
						|
				if (!str)
 | 
						|
					str = "";
 | 
						|
				printf("\t\"\\x%02x\\x%02x\"\"%s\"\n",
 | 
						|
				       i, j, str);
 | 
						|
			} else if (str) {
 | 
						|
				printf("#if REQUIRED_MASK%d & (1 << %d)\n"
 | 
						|
				       "\t\"\\x%02x\\x%02x\"\"%s\\0\"\n"
 | 
						|
				       "#endif\n",
 | 
						|
				       i, j, i, j, str);
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	printf("\t;\n");
 | 
						|
	return 0;
 | 
						|
}
 |