Project

General

Profile

Actions

Submit #2363

closed

Port of FreeBSD clflush and smbios.c

Added by davshao almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
05/07/2012
Due date:
% Done:

0%

Estimated time:

Description

Port from FreeBSD of function wrapping asm for clflush, required for latest DRM kernel graphics drivers.
(Reference: http://people.freebsd.org/~kib/drm/)

In addition smbios.c has been ported because FreeBSD uses resulting values to decide whether CLFLUSH can
be enabled on virtual machines.

Users can now report (notoriously unreliable) smbios values from kenv.

Ported ability to disable CLFLUSH using set hw.clflush_disable=1.

The function for clflush has not been tested yet.

There may be some concern that adding smbios.c to loader code may lead to unbootable systems for
code that is nonessential; however, the code has not led to unbootable systems on an Asus P4B266
Pentium 4, a Lenovo S10 netbook, an Asus M5A87 amd64, an Asus ULFT20, and Vmware Fusion 3.1.4.

The current port of accompanying vm detection code for clflush is obviously of
cargo-cult quality because some applies to xen and not to vkernels.


Files

clflush.diff (24.2 KB) clflush.diff Patch for clflush port davshao, 05/07/2012 02:07 PM
Actions #1

Updated by vsrinivas almost 12 years ago

Hi,

I took a look at the patch, have a few comments:

1) SMBIOS to detect bios vendor and decide if you are in a VMM is not my favourite approach. CPUID2_VMM is available in one extended set of CPUID feature flags:
if (cpu_feature2 & CPUID2_VMM) { /* I am in a VMM! */ }

2) Tiny thing, I'd like to see all of the VM_ and vm_ fields added as VMM_ and vmm_; traditionally, vm_* refer to the virtual memory code.

3) Why do you if-0 out the prototype of initializecpu()?
#if 0
+void initializecpu(void);
#endif

4) The convention of having 'vm(m)_guest' available is a good one. We could convert the APIC enable code to use it as well.

5) Just a question -- on systems w/o CLFLUSH, what does the DRM code do? Does it just use WBINVD?

Thanks,

Actions #2

Updated by vsrinivas almost 12 years ago

http://leaf.dragonflybsd.org/~vsrinivas/0001-kernel-vmm_guest-CLFLUSH.patch

is a simplified version of this patch. It does not have sysctl/tunable to enable CLFLUSH and it uses CPUID's VMM field rather than SMBIOS to detect a VMM. Seems to work here though.

Is this patch suitable for what you need? Does it look better to folks?

--vs;

Actions #3

Updated by vsrinivas almost 12 years ago

Commit 087717516887f81d5df331b8118745d0abd26161 should provide CLFLUSH and VM detection. David, good for you DRM purposes?

Actions #4

Updated by vsrinivas almost 12 years ago

  • Status changed from New to Feedback
Actions #5

Updated by swildner over 11 years ago

  • Status changed from Feedback to Closed

The CLFLUSH part was pushed (using VMM cpu_feature2) and recently I pushed smbios too (hadn't noticed it was submitted with this report, sorry).

If there are any problems, please feel free to re-open and comment.

Actions

Also available in: Atom PDF