Skip to content

Commit a94fc25

Browse files
committed
Merge tag 'for-linus-4.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen updates from Juergen Gross: "This contains some minor code cleanups (fixing return types of functions), some fixes for Linux running as Xen PVH guest, and adding of a new guest resource mapping feature for Xen tools" * tag 'for-linus-4.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/PVH: Make GDT selectors PVH-specific xen/PVH: Set up GS segment for stack canary xen/store: do not store local values in xen_start_info xen-netfront: fix xennet_start_xmit()'s return type xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE xen: Change return type to vm_fault_t
2 parents 68abbe7 + 7f47e1c commit a94fc25

File tree

10 files changed

+332
-36
lines changed

10 files changed

+332
-36
lines changed

arch/arm/xen/enlighten.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
8989
}
9090
EXPORT_SYMBOL_GPL(xen_unmap_domain_gfn_range);
9191

92+
/* Not used by XENFEAT_auto_translated guests. */
93+
int xen_remap_domain_mfn_array(struct vm_area_struct *vma,
94+
unsigned long addr,
95+
xen_pfn_t *mfn, int nr,
96+
int *err_ptr, pgprot_t prot,
97+
unsigned int domid, struct page **pages)
98+
{
99+
return -ENOSYS;
100+
}
101+
EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_array);
102+
92103
static void xen_read_wallclock(struct timespec64 *ts)
93104
{
94105
u32 version;

arch/x86/xen/mmu.c

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,37 +63,44 @@ static noinline void xen_flush_tlb_all(void)
6363
#define REMAP_BATCH_SIZE 16
6464

6565
struct remap_data {
66-
xen_pfn_t *mfn;
66+
xen_pfn_t *pfn;
6767
bool contiguous;
68+
bool no_translate;
6869
pgprot_t prot;
6970
struct mmu_update *mmu_update;
7071
};
7172

72-
static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,
73+
static int remap_area_pfn_pte_fn(pte_t *ptep, pgtable_t token,
7374
unsigned long addr, void *data)
7475
{
7576
struct remap_data *rmd = data;
76-
pte_t pte = pte_mkspecial(mfn_pte(*rmd->mfn, rmd->prot));
77+
pte_t pte = pte_mkspecial(mfn_pte(*rmd->pfn, rmd->prot));
7778

78-
/* If we have a contiguous range, just update the mfn itself,
79-
else update pointer to be "next mfn". */
79+
/*
80+
* If we have a contiguous range, just update the pfn itself,
81+
* else update pointer to be "next pfn".
82+
*/
8083
if (rmd->contiguous)
81-
(*rmd->mfn)++;
84+
(*rmd->pfn)++;
8285
else
83-
rmd->mfn++;
86+
rmd->pfn++;
8487

85-
rmd->mmu_update->ptr = virt_to_machine(ptep).maddr | MMU_NORMAL_PT_UPDATE;
88+
rmd->mmu_update->ptr = virt_to_machine(ptep).maddr;
89+
rmd->mmu_update->ptr |= rmd->no_translate ?
90+
MMU_PT_UPDATE_NO_TRANSLATE :
91+
MMU_NORMAL_PT_UPDATE;
8692
rmd->mmu_update->val = pte_val_ma(pte);
8793
rmd->mmu_update++;
8894

8995
return 0;
9096
}
9197

92-
static int do_remap_gfn(struct vm_area_struct *vma,
98+
static int do_remap_pfn(struct vm_area_struct *vma,
9399
unsigned long addr,
94-
xen_pfn_t *gfn, int nr,
100+
xen_pfn_t *pfn, int nr,
95101
int *err_ptr, pgprot_t prot,
96-
unsigned domid,
102+
unsigned int domid,
103+
bool no_translate,
97104
struct page **pages)
98105
{
99106
int err = 0;
@@ -104,11 +111,14 @@ static int do_remap_gfn(struct vm_area_struct *vma,
104111

105112
BUG_ON(!((vma->vm_flags & (VM_PFNMAP | VM_IO)) == (VM_PFNMAP | VM_IO)));
106113

107-
rmd.mfn = gfn;
114+
rmd.pfn = pfn;
108115
rmd.prot = prot;
109-
/* We use the err_ptr to indicate if there we are doing a contiguous
110-
* mapping or a discontigious mapping. */
116+
/*
117+
* We use the err_ptr to indicate if there we are doing a contiguous
118+
* mapping or a discontigious mapping.
119+
*/
111120
rmd.contiguous = !err_ptr;
121+
rmd.no_translate = no_translate;
112122

113123
while (nr) {
114124
int index = 0;
@@ -119,7 +129,7 @@ static int do_remap_gfn(struct vm_area_struct *vma,
119129

120130
rmd.mmu_update = mmu_update;
121131
err = apply_to_page_range(vma->vm_mm, addr, range,
122-
remap_area_mfn_pte_fn, &rmd);
132+
remap_area_pfn_pte_fn, &rmd);
123133
if (err)
124134
goto out;
125135

@@ -173,7 +183,8 @@ int xen_remap_domain_gfn_range(struct vm_area_struct *vma,
173183
if (xen_feature(XENFEAT_auto_translated_physmap))
174184
return -EOPNOTSUPP;
175185

176-
return do_remap_gfn(vma, addr, &gfn, nr, NULL, prot, domid, pages);
186+
return do_remap_pfn(vma, addr, &gfn, nr, NULL, prot, domid, false,
187+
pages);
177188
}
178189
EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_range);
179190

@@ -192,10 +203,25 @@ int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
192203
* cause of "wrong memory was mapped in".
193204
*/
194205
BUG_ON(err_ptr == NULL);
195-
return do_remap_gfn(vma, addr, gfn, nr, err_ptr, prot, domid, pages);
206+
return do_remap_pfn(vma, addr, gfn, nr, err_ptr, prot, domid,
207+
false, pages);
196208
}
197209
EXPORT_SYMBOL_GPL(xen_remap_domain_gfn_array);
198210

211+
int xen_remap_domain_mfn_array(struct vm_area_struct *vma,
212+
unsigned long addr,
213+
xen_pfn_t *mfn, int nr,
214+
int *err_ptr, pgprot_t prot,
215+
unsigned int domid, struct page **pages)
216+
{
217+
if (xen_feature(XENFEAT_auto_translated_physmap))
218+
return -EOPNOTSUPP;
219+
220+
return do_remap_pfn(vma, addr, mfn, nr, err_ptr, prot, domid,
221+
true, pages);
222+
}
223+
EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_array);
224+
199225
/* Returns: 0 success */
200226
int xen_unmap_domain_gfn_range(struct vm_area_struct *vma,
201227
int nr, struct page **pages)

arch/x86/xen/xen-pvh.S

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,19 @@
5454
* charge of setting up it's own stack, GDT and IDT.
5555
*/
5656

57+
#define PVH_GDT_ENTRY_CS 1
58+
#define PVH_GDT_ENTRY_DS 2
59+
#define PVH_GDT_ENTRY_CANARY 3
60+
#define PVH_CS_SEL (PVH_GDT_ENTRY_CS * 8)
61+
#define PVH_DS_SEL (PVH_GDT_ENTRY_DS * 8)
62+
#define PVH_CANARY_SEL (PVH_GDT_ENTRY_CANARY * 8)
63+
5764
ENTRY(pvh_start_xen)
5865
cld
5966

6067
lgdt (_pa(gdt))
6168

62-
mov $(__BOOT_DS),%eax
69+
mov $PVH_DS_SEL,%eax
6370
mov %eax,%ds
6471
mov %eax,%es
6572
mov %eax,%ss
@@ -93,11 +100,17 @@ ENTRY(pvh_start_xen)
93100
mov %eax, %cr0
94101

95102
/* Jump to 64-bit mode. */
96-
ljmp $__KERNEL_CS, $_pa(1f)
103+
ljmp $PVH_CS_SEL, $_pa(1f)
97104

98105
/* 64-bit entry point. */
99106
.code64
100107
1:
108+
/* Set base address in stack canary descriptor. */
109+
mov $MSR_GS_BASE,%ecx
110+
mov $_pa(canary), %eax
111+
xor %edx, %edx
112+
wrmsr
113+
101114
call xen_prepare_pvh
102115

103116
/* startup_64 expects boot_params in %rsi. */
@@ -107,6 +120,17 @@ ENTRY(pvh_start_xen)
107120

108121
#else /* CONFIG_X86_64 */
109122

123+
/* Set base address in stack canary descriptor. */
124+
movl $_pa(gdt_start),%eax
125+
movl $_pa(canary),%ecx
126+
movw %cx, (PVH_GDT_ENTRY_CANARY * 8) + 2(%eax)
127+
shrl $16, %ecx
128+
movb %cl, (PVH_GDT_ENTRY_CANARY * 8) + 4(%eax)
129+
movb %ch, (PVH_GDT_ENTRY_CANARY * 8) + 7(%eax)
130+
131+
mov $PVH_CANARY_SEL,%eax
132+
mov %eax,%gs
133+
110134
call mk_early_pgtbl_32
111135

112136
mov $_pa(initial_page_table), %eax
@@ -116,13 +140,13 @@ ENTRY(pvh_start_xen)
116140
or $(X86_CR0_PG | X86_CR0_PE), %eax
117141
mov %eax, %cr0
118142

119-
ljmp $__BOOT_CS, $1f
143+
ljmp $PVH_CS_SEL, $1f
120144
1:
121145
call xen_prepare_pvh
122146
mov $_pa(pvh_bootparams), %esi
123147

124148
/* startup_32 doesn't expect paging and PAE to be on. */
125-
ljmp $__BOOT_CS, $_pa(2f)
149+
ljmp $PVH_CS_SEL, $_pa(2f)
126150
2:
127151
mov %cr0, %eax
128152
and $~X86_CR0_PG, %eax
@@ -131,7 +155,7 @@ ENTRY(pvh_start_xen)
131155
and $~X86_CR4_PAE, %eax
132156
mov %eax, %cr4
133157

134-
ljmp $__BOOT_CS, $_pa(startup_32)
158+
ljmp $PVH_CS_SEL, $_pa(startup_32)
135159
#endif
136160
END(pvh_start_xen)
137161

@@ -143,16 +167,19 @@ gdt:
143167
.word 0
144168
gdt_start:
145169
.quad 0x0000000000000000 /* NULL descriptor */
146-
.quad 0x0000000000000000 /* reserved */
147170
#ifdef CONFIG_X86_64
148-
.quad GDT_ENTRY(0xa09a, 0, 0xfffff) /* __KERNEL_CS */
171+
.quad GDT_ENTRY(0xa09a, 0, 0xfffff) /* PVH_CS_SEL */
149172
#else
150-
.quad GDT_ENTRY(0xc09a, 0, 0xfffff) /* __KERNEL_CS */
173+
.quad GDT_ENTRY(0xc09a, 0, 0xfffff) /* PVH_CS_SEL */
151174
#endif
152-
.quad GDT_ENTRY(0xc092, 0, 0xfffff) /* __KERNEL_DS */
175+
.quad GDT_ENTRY(0xc092, 0, 0xfffff) /* PVH_DS_SEL */
176+
.quad GDT_ENTRY(0x4090, 0, 0x18) /* PVH_CANARY_SEL */
153177
gdt_end:
154178

155-
.balign 4
179+
.balign 16
180+
canary:
181+
.fill 48, 1, 0
182+
156183
early_stack:
157184
.fill 256, 1, 0
158185
early_stack_end:

drivers/net/xen-netfront.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ static u16 xennet_select_queue(struct net_device *dev, struct sk_buff *skb,
564564

565565
#define MAX_XEN_SKB_FRAGS (65536 / XEN_PAGE_SIZE + 1)
566566

567-
static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
567+
static netdev_tx_t xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
568568
{
569569
struct netfront_info *np = netdev_priv(dev);
570570
struct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats);

0 commit comments

Comments
 (0)