/root/src/xen/xen/arch/x86/hvm/svm/asid.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * asid.c: handling ASIDs in SVM. |
3 | | * Copyright (c) 2007, Advanced Micro Devices, Inc. |
4 | | * |
5 | | * This program is free software; you can redistribute it and/or modify it |
6 | | * under the terms and conditions of the GNU General Public License, |
7 | | * version 2, as published by the Free Software Foundation. |
8 | | * |
9 | | * This program is distributed in the hope it will be useful, but WITHOUT |
10 | | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12 | | * more details. |
13 | | * |
14 | | * You should have received a copy of the GNU General Public License along with |
15 | | * this program; If not, see <http://www.gnu.org/licenses/>. |
16 | | */ |
17 | | |
18 | | #include <xen/init.h> |
19 | | #include <xen/lib.h> |
20 | | #include <xen/perfc.h> |
21 | | #include <asm/hvm/svm/asid.h> |
22 | | #include <asm/amd.h> |
23 | | #include <asm/hvm/nestedhvm.h> |
24 | | |
25 | | void svm_asid_init(const struct cpuinfo_x86 *c) |
26 | 0 | { |
27 | 0 | int nasids = 0; |
28 | 0 |
|
29 | 0 | /* Check for erratum #170, and leave ASIDs disabled if it's present. */ |
30 | 0 | if ( !cpu_has_amd_erratum(c, AMD_ERRATUM_170) ) |
31 | 0 | nasids = cpuid_ebx(0x8000000A); |
32 | 0 |
|
33 | 0 | hvm_asid_init(nasids); |
34 | 0 | } |
35 | | |
36 | | /* |
37 | | * Called directly before VMRUN. Checks if the VCPU needs a new ASID, |
38 | | * assigns it, and if required, issues required TLB flushes. |
39 | | */ |
40 | | void svm_asid_handle_vmrun(void) |
41 | 0 | { |
42 | 0 | struct vcpu *curr = current; |
43 | 0 | struct vmcb_struct *vmcb = curr->arch.hvm_svm.vmcb; |
44 | 0 | struct hvm_vcpu_asid *p_asid = |
45 | 0 | nestedhvm_vcpu_in_guestmode(curr) |
46 | 0 | ? &vcpu_nestedhvm(curr).nv_n2asid : &curr->arch.hvm_vcpu.n1asid; |
47 | 0 | bool_t need_flush = hvm_asid_handle_vmenter(p_asid); |
48 | 0 |
|
49 | 0 | /* ASID 0 indicates that ASIDs are disabled. */ |
50 | 0 | if ( p_asid->asid == 0 ) |
51 | 0 | { |
52 | 0 | vmcb_set_guest_asid(vmcb, 1); |
53 | 0 | vmcb->tlb_control = 1; |
54 | 0 | return; |
55 | 0 | } |
56 | 0 |
|
57 | 0 | if (vmcb_get_guest_asid(vmcb) != p_asid->asid) |
58 | 0 | vmcb_set_guest_asid(vmcb, p_asid->asid); |
59 | 0 | vmcb->tlb_control = need_flush; |
60 | 0 | } |
61 | | |
62 | | /* |
63 | | * Local variables: |
64 | | * mode: C |
65 | | * c-file-style: "BSD" |
66 | | * c-basic-offset: 4 |
67 | | * tab-width: 4 |
68 | | * indent-tabs-mode: nil |
69 | | * End: |
70 | | */ |