Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Dec 1997 15:56:53 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        jkh@FreeBSD.ORG, Studded@dal.net
Cc:        cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-sys@FreeBSD.ORG
Subject:   Re: cvs commit: src/sys/i386/i386 identcpu.c machdep.c trap.c
Message-ID:  <199712060456.PAA30883@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> jkh         1997/12/04 06:36:58 PST
>> 
>>   Modified files:        (Branch: RELENG_2_2)
>>     sys/i386/i386        identcpu.c machdep.c trap.c
>>   Log:
>>   MFC: F00F cleanup.
>> 
>>   Revision  Changes    Path
>>   1.7.2.12  +3 -3      src/sys/i386/i386/identcpu.c
>>   1.209.2.16 +4 -4      src/sys/i386/i386/machdep.c
>>   1.83.2.4  +5 -5      src/sys/i386/i386/trap.c
>
>	I'm still getting the errors in the first attachment when compiling the
>kernel with -Wall on 2.2.5-Stable. Even if it's not compiled with -Wall,
>it's still giving errors, which people on -questions have asked about
>already. Given that this is supposed to be a "bug fix" I think it
>behooves us to make at least machdep.c compile clean. I realize that
>these errors probably are not significant, and if I could fix them I
>would. 

I fixed the warnings and style bugs but am not ready to commit anything yet
(the new idt can be allocated better...).

>cc -c -O -Wall -pipe -Wreturn-type -Wcomment -Wredundant-decls -Wimplicit  -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes  -Wpointer-arith  -nostdinc -I- -I. -I../.. -I../../../include -DCOMPAT_43 -DMSDOSFS -DFFS -DINET -DKERNEL  ../../i386/i38
>6/machdep.c
>../../i386/i386/machdep.c: In function `cpu_startup':
>../../i386/i386/machdep.c:231: warning: long unsigned int format, unsigned int arg (arg 2)
>../../i386/i386/machdep.c:231: warning: long unsigned int format, unsigned int arg (arg 3)

Don't use -Wall unless you want to work on fixing the small problems it 
exposes.

Bruce

diff -c2 machdep.c~ machdep.c
*** machdep.c~	Fri Dec  5 16:10:32 1997
--- machdep.c	Sat Dec  6 15:34:39 1997
***************
*** 1537,1575 ****
  	proc0.p_addr->u_pcb.pcb_flags = 0;
  	proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD;
  	proc0.p_addr->u_pcb.pcb_mpnest = 1;
  	proc0.p_addr->u_pcb.pcb_ext = 0;
  }
  
  #if defined(I586_CPU) && !defined(NO_F00F_HACK)
! void f00f_hack(void);
! SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL);
  
  void
! f00f_hack(void) {
  	struct region_descriptor r_idt;
! 	unsigned char *tmp;
! 	int i;
  
  	if (!has_f00f_bug)
  		return;
! 
! 	printf("Intel Pentium F00F detected, installing workaround\n");
! 
! 	r_idt.rd_limit = sizeof(idt) - 1;
! 
  	tmp = kmem_alloc(kernel_map, PAGE_SIZE * 2);
  	if (tmp == 0)
  		panic("kmem_alloc returned 0");
! 	if (((unsigned int)tmp & (PAGE_SIZE-1)) != 0)
! 		panic("kmem_alloc returned non-page-aligned memory");
! 	/* Put the first seven entries in the lower page */
! 	t_idt = (struct gate_descriptor*)(tmp + PAGE_SIZE - (7*8));
  	bcopy(idt, t_idt, sizeof(idt));
! 	r_idt.rd_base = (int)t_idt;
! 	lidt(&r_idt);
! 	if (vm_map_protect(kernel_map, tmp, tmp + PAGE_SIZE,
! 			   VM_PROT_READ, FALSE) != KERN_SUCCESS)
  		panic("vm_map_protect failed");
! 	return;
  }
  #endif /* defined(I586_CPU) && !NO_F00F_HACK */
--- 1595,1635 ----
  	proc0.p_addr->u_pcb.pcb_flags = 0;
  	proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD;
+ #ifdef SMP
  	proc0.p_addr->u_pcb.pcb_mpnest = 1;
+ #endif
+ #ifdef VM86
  	proc0.p_addr->u_pcb.pcb_ext = 0;
+ #endif
  }
  
  #if defined(I586_CPU) && !defined(NO_F00F_HACK)
! static void f00f_hack __P((void *unused));
! SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL)
  
  void
! f00f_hack(unused)
! 	void *unused;
! {
  	struct region_descriptor r_idt;
! 	vm_offset_t tmp;
  
  	if (!has_f00f_bug)
  		return;
! 	printf("Intel Pentium detected, installing workaround for F00F bug\n");
  	tmp = kmem_alloc(kernel_map, PAGE_SIZE * 2);
  	if (tmp == 0)
  		panic("kmem_alloc returned 0");
! 
! 	/* Put the problematic entry (#6) at the end of the lower page. */
! 	t_idt = (struct gate_descriptor *)
! 	    (tmp + PAGE_SIZE - 7 * sizeof(struct gate_descriptor));
! 
  	bcopy(idt, t_idt, sizeof(idt));
! 	if (vm_map_protect(kernel_map, tmp, tmp + PAGE_SIZE, VM_PROT_READ,
! 	    FALSE) != KERN_SUCCESS)
  		panic("vm_map_protect failed");
! 	r_idt.rd_limit = sizeof(idt) - 1;
! 	r_idt.rd_base = (unsigned)t_idt;
! 	lidt(&r_idt);
  }
  #endif /* defined(I586_CPU) && !NO_F00F_HACK */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712060456.PAA30883>