Skip to content

Commit 699f675

Browse files
Jacob PanKAGA-KOKO
authored andcommitted
KVM: VMX: Move posted interrupt descriptor out of VMX code
To prepare native usage of posted interrupts, move the PID declarations out of VMX code such that they can be shared. Signed-off-by: Jacob Pan <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ed30a4a commit 699f675

File tree

4 files changed

+91
-93
lines changed

4 files changed

+91
-93
lines changed

arch/x86/include/asm/posted_intr.h

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _X86_POSTED_INTR_H
3+
#define _X86_POSTED_INTR_H
4+
5+
#define POSTED_INTR_ON 0
6+
#define POSTED_INTR_SN 1
7+
8+
#define PID_TABLE_ENTRY_VALID 1
9+
10+
/* Posted-Interrupt Descriptor */
11+
struct pi_desc {
12+
u32 pir[8]; /* Posted interrupt requested */
13+
union {
14+
struct {
15+
/* bit 256 - Outstanding Notification */
16+
u16 on : 1,
17+
/* bit 257 - Suppress Notification */
18+
sn : 1,
19+
/* bit 271:258 - Reserved */
20+
rsvd_1 : 14;
21+
/* bit 279:272 - Notification Vector */
22+
u8 nv;
23+
/* bit 287:280 - Reserved */
24+
u8 rsvd_2;
25+
/* bit 319:288 - Notification Destination */
26+
u32 ndst;
27+
};
28+
u64 control;
29+
};
30+
u32 rsvd[6];
31+
} __aligned(64);
32+
33+
static inline bool pi_test_and_set_on(struct pi_desc *pi_desc)
34+
{
35+
return test_and_set_bit(POSTED_INTR_ON, (unsigned long *)&pi_desc->control);
36+
}
37+
38+
static inline bool pi_test_and_clear_on(struct pi_desc *pi_desc)
39+
{
40+
return test_and_clear_bit(POSTED_INTR_ON, (unsigned long *)&pi_desc->control);
41+
}
42+
43+
static inline bool pi_test_and_clear_sn(struct pi_desc *pi_desc)
44+
{
45+
return test_and_clear_bit(POSTED_INTR_SN, (unsigned long *)&pi_desc->control);
46+
}
47+
48+
static inline bool pi_test_and_set_pir(int vector, struct pi_desc *pi_desc)
49+
{
50+
return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
51+
}
52+
53+
static inline bool pi_is_pir_empty(struct pi_desc *pi_desc)
54+
{
55+
return bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS);
56+
}
57+
58+
static inline void pi_set_sn(struct pi_desc *pi_desc)
59+
{
60+
set_bit(POSTED_INTR_SN, (unsigned long *)&pi_desc->control);
61+
}
62+
63+
static inline void pi_set_on(struct pi_desc *pi_desc)
64+
{
65+
set_bit(POSTED_INTR_ON, (unsigned long *)&pi_desc->control);
66+
}
67+
68+
static inline void pi_clear_on(struct pi_desc *pi_desc)
69+
{
70+
clear_bit(POSTED_INTR_ON, (unsigned long *)&pi_desc->control);
71+
}
72+
73+
static inline void pi_clear_sn(struct pi_desc *pi_desc)
74+
{
75+
clear_bit(POSTED_INTR_SN, (unsigned long *)&pi_desc->control);
76+
}
77+
78+
static inline bool pi_test_on(struct pi_desc *pi_desc)
79+
{
80+
return test_bit(POSTED_INTR_ON, (unsigned long *)&pi_desc->control);
81+
}
82+
83+
static inline bool pi_test_sn(struct pi_desc *pi_desc)
84+
{
85+
return test_bit(POSTED_INTR_SN, (unsigned long *)&pi_desc->control);
86+
}
87+
88+
#endif /* _X86_POSTED_INTR_H */

arch/x86/kvm/vmx/posted_intr.h

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#ifndef __KVM_X86_VMX_POSTED_INTR_H
33
#define __KVM_X86_VMX_POSTED_INTR_H
4-
5-
#define POSTED_INTR_ON 0
6-
#define POSTED_INTR_SN 1
7-
8-
#define PID_TABLE_ENTRY_VALID 1
9-
10-
/* Posted-Interrupt Descriptor */
11-
struct pi_desc {
12-
u32 pir[8]; /* Posted interrupt requested */
13-
union {
14-
struct {
15-
/* bit 256 - Outstanding Notification */
16-
u16 on : 1,
17-
/* bit 257 - Suppress Notification */
18-
sn : 1,
19-
/* bit 271:258 - Reserved */
20-
rsvd_1 : 14;
21-
/* bit 279:272 - Notification Vector */
22-
u8 nv;
23-
/* bit 287:280 - Reserved */
24-
u8 rsvd_2;
25-
/* bit 319:288 - Notification Destination */
26-
u32 ndst;
27-
};
28-
u64 control;
29-
};
30-
u32 rsvd[6];
31-
} __aligned(64);
32-
33-
static inline bool pi_test_and_set_on(struct pi_desc *pi_desc)
34-
{
35-
return test_and_set_bit(POSTED_INTR_ON,
36-
(unsigned long *)&pi_desc->control);
37-
}
38-
39-
static inline bool pi_test_and_clear_on(struct pi_desc *pi_desc)
40-
{
41-
return test_and_clear_bit(POSTED_INTR_ON,
42-
(unsigned long *)&pi_desc->control);
43-
}
44-
45-
static inline bool pi_test_and_clear_sn(struct pi_desc *pi_desc)
46-
{
47-
return test_and_clear_bit(POSTED_INTR_SN,
48-
(unsigned long *)&pi_desc->control);
49-
}
50-
51-
static inline bool pi_test_and_set_pir(int vector, struct pi_desc *pi_desc)
52-
{
53-
return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
54-
}
55-
56-
static inline bool pi_is_pir_empty(struct pi_desc *pi_desc)
57-
{
58-
return bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS);
59-
}
60-
61-
static inline void pi_set_sn(struct pi_desc *pi_desc)
62-
{
63-
set_bit(POSTED_INTR_SN,
64-
(unsigned long *)&pi_desc->control);
65-
}
66-
67-
static inline void pi_set_on(struct pi_desc *pi_desc)
68-
{
69-
set_bit(POSTED_INTR_ON,
70-
(unsigned long *)&pi_desc->control);
71-
}
72-
73-
static inline void pi_clear_on(struct pi_desc *pi_desc)
74-
{
75-
clear_bit(POSTED_INTR_ON,
76-
(unsigned long *)&pi_desc->control);
77-
}
78-
79-
static inline void pi_clear_sn(struct pi_desc *pi_desc)
80-
{
81-
clear_bit(POSTED_INTR_SN,
82-
(unsigned long *)&pi_desc->control);
83-
}
84-
85-
static inline bool pi_test_on(struct pi_desc *pi_desc)
86-
{
87-
return test_bit(POSTED_INTR_ON,
88-
(unsigned long *)&pi_desc->control);
89-
}
90-
91-
static inline bool pi_test_sn(struct pi_desc *pi_desc)
92-
{
93-
return test_bit(POSTED_INTR_SN,
94-
(unsigned long *)&pi_desc->control);
95-
}
4+
#include <asm/posted_intr.h>
965

976
void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu);
987
void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu);

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include "x86.h"
7171
#include "smm.h"
7272
#include "vmx_onhyperv.h"
73+
#include "posted_intr.h"
7374

7475
MODULE_AUTHOR("Qumranet");
7576
MODULE_LICENSE("GPL");

arch/x86/kvm/vmx/vmx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#include <asm/kvm.h>
88
#include <asm/intel_pt.h>
99
#include <asm/perf_event.h>
10+
#include <asm/posted_intr.h>
1011

1112
#include "capabilities.h"
1213
#include "../kvm_cache_regs.h"
13-
#include "posted_intr.h"
1414
#include "vmcs.h"
1515
#include "vmx_ops.h"
1616
#include "../cpuid.h"

0 commit comments

Comments
 (0)