2009-06-03 01:17:38 +04:00
/ *
* This f i l e c o n t a i n s t h e 6 4 - b i t " s e r v e r " P o w e r P C v a r i a n t
* of t h e l o w l e v e l e x c e p t i o n h a n d l i n g i n c l u d i n g e x c e p t i o n
* vectors, e x c e p t i o n r e t u r n , p a r t o f t h e s l b a n d s t a b
* handling a n d o t h e r f i x e d o f f s e t s p e c i f i c t h i n g s .
*
* This f i l e i s m e a n t t o b e #i n c l u d e d f r o m h e a d _ 64 . S d u e t o
2011-03-31 05:57:33 +04:00
* position d e p e n d e n t a s s e m b l y .
2009-06-03 01:17:38 +04:00
*
* Most o f t h i s o r i g i n a t e s f r o m h e a d _ 6 4 . S a n d t h u s h a s t h e s a m e
* copyright h i s t o r y .
*
* /
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
# include < a s m / h w _ i r q . h >
2009-07-15 00:52:52 +04:00
# include < a s m / e x c e p t i o n - 6 4 s . h >
2010-11-18 18:06:17 +03:00
# include < a s m / p t r a c e . h >
2009-07-15 00:52:52 +04:00
2009-06-03 01:17:38 +04:00
/ *
* We l a y o u t p h y s i c a l m e m o r y a s f o l l o w s :
* 0 x0 0 0 0 - 0 x00 f f : S e c o n d a r y p r o c e s s o r s p i n c o d e
2012-11-02 10:21:43 +04:00
* 0 x0 1 0 0 - 0 x17 f f : p S e r i e s I n t e r r u p t p r o l o g s
* 0 x1 8 0 0 - 0 x40 0 0 : i n t e r r u p t s u p p o r t c o m m o n i n t e r r u p t p r o l o g s
* 0 x4 0 0 0 - 0 x5 f f f : p S e r i e s i n t e r r u p t s w i t h I R =1 ,D R =1
* 0 x6 0 0 0 - 0 x6 f f f : m o r e i n t e r r u p t s u p p o r t i n c l u d i n g f o r I R =1 ,D R =1
2009-06-03 01:17:38 +04:00
* 0 x7 0 0 0 - 0 x7 f f f : F W N M I d a t a a r e a
2012-11-02 10:21:43 +04:00
* 0 x8 0 0 0 - 0 x8 f f f : I n i t i a l ( C P U 0 ) s e g m e n t t a b l e
* 0 x9 0 0 0 - : E a r l y i n i t a n d s u p p o r t c o d e
2009-06-03 01:17:38 +04:00
* /
2012-11-02 10:16:01 +04:00
/* Syscall routine is used twice, in reloc-off and reloc-on paths */
# define S Y S C A L L _ P S E R I E S _ 1 \
BEGIN_ F T R _ S E C T I O N \
cmpdi r0 ,0 x1 e b e ; \
beq- 1 f ; \
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ R E A L _ L E ) \
mr r9 ,r13 ; \
GET_ P A C A ( r13 ) ; \
mfspr r11 ,S P R N _ S R R 0 ; \
0 :
# define S Y S C A L L _ P S E R I E S _ 2 _ R F I D \
mfspr r12 ,S P R N _ S R R 1 ; \
ld r10 ,P A C A K B A S E ( r13 ) ; \
LOAD_ H A N D L E R ( r10 , s y s t e m _ c a l l _ e n t r y ) ; \
mtspr S P R N _ S R R 0 ,r10 ; \
ld r10 ,P A C A K M S R ( r13 ) ; \
mtspr S P R N _ S R R 1 ,r10 ; \
rfid ; \
b . ; /* prevent speculative execution */
# define S Y S C A L L _ P S E R I E S _ 3 \
/* Fast LE/BE switch system call */ \
1 : mfspr r12 ,S P R N _ S R R 1 ; \
xori r12 ,r12 ,M S R _ L E ; \
mtspr S P R N _ S R R 1 ,r12 ; \
rfid ; /* return to userspace */ \
b . ; \
2 : mfspr r12 ,S P R N _ S R R 1 ; \
andi. r12 ,r12 ,M S R _ P R ; \
bne 0 b ; \
mtspr S P R N _ S R R 0 ,r3 ; \
mtspr S P R N _ S R R 1 ,r4 ; \
mtspr S P R N _ S D R 1 ,r5 ; \
rfid ; \
b . ; /* prevent speculative execution */
2012-11-02 10:21:28 +04:00
# if d e f i n e d ( C O N F I G _ R E L O C A T A B L E )
/ *
* We c a n ' t b r a n c h d i r e c t l y ; in the direct case we use LR
* and s y s t e m _ c a l l _ e n t r y r e s t o r e s L R . ( W e t h u s n e e d t o m o v e
* LR t o r10 i n t h e R F I D c a s e t o o . )
* /
# define S Y S C A L L _ P S E R I E S _ 2 _ D I R E C T \
mflr r10 ; \
ld r12 ,P A C A K B A S E ( r13 ) ; \
LOAD_ H A N D L E R ( r12 , s y s t e m _ c a l l _ e n t r y _ d i r e c t ) ; \
mtlr r12 ; \
mfspr r12 ,S P R N _ S R R 1 ; \
/* Re-use of r13... No spare regs to do this */ \
li r13 ,M S R _ R I ; \
mtmsrd r13 ,1 ; \
GET_ P A C A ( r13 ) ; /* get r13 back */ \
blr ;
# else
/* We can branch directly */
# define S Y S C A L L _ P S E R I E S _ 2 _ D I R E C T \
mfspr r12 ,S P R N _ S R R 1 ; \
li r10 ,M S R _ R I ; \
mtmsrd r10 ,1 ; /* Set RI (EE=0) */ \
b s y s t e m _ c a l l _ e n t r y _ d i r e c t ;
# endif
2009-06-03 01:17:38 +04:00
/ *
* This i s t h e s t a r t o f t h e i n t e r r u p t h a n d l e r s f o r p S e r i e s
* This c o d e r u n s w i t h r e l o c a t i o n o f f .
* Code f r o m h e r e t o _ _ e n d _ i n t e r r u p t s g e t s c o p i e d d o w n t o r e a l
* address 0 x10 0 w h e n w e a r e r u n n i n g a r e l o c a t a b l e k e r n e l .
* Therefore a n y r e l a t i v e b r a n c h e s i n t h i s s e c t i o n m u s t o n l y
* branch t o l a b e l s i n t h i s s e c t i o n .
* /
. = 0 x1 0 0
.globl __start_interrupts
__start_interrupts :
2011-01-24 10:42:41 +03:00
.globl system_ r e s e t _ p S e r i e s ;
system_reset_pSeries :
HMT_ M E D I U M ;
SET_ S C R A T C H 0 ( r13 )
# ifdef C O N F I G _ P P C _ P 7 _ N A P
BEGIN_ F T R _ S E C T I O N
/ * Running n a t i v e o n a r c h 2 . 0 6 o r l a t e r , c h e c k i f w e a r e
* waking u p f r o m n a p . W e o n l y h a n d l e n o s t a t e l o s s a n d
* supervisor s t a t e l o s s . W e d o - n o t - h a n d l e h y p e r v i s o r
* state l o s s a t t h i s t i m e .
* /
mfspr r13 ,S P R N _ S R R 1
KVM: PPC: Allow book3s_hv guests to use SMT processor modes
This lifts the restriction that book3s_hv guests can only run one
hardware thread per core, and allows them to use up to 4 threads
per core on POWER7. The host still has to run single-threaded.
This capability is advertised to qemu through a new KVM_CAP_PPC_SMT
capability. The return value of the ioctl querying this capability
is the number of vcpus per virtual CPU core (vcore), currently 4.
To use this, the host kernel should be booted with all threads
active, and then all the secondary threads should be offlined.
This will put the secondary threads into nap mode. KVM will then
wake them from nap mode and use them for running guest code (while
they are still offline). To wake the secondary threads, we send
them an IPI using a new xics_wake_cpu() function, implemented in
arch/powerpc/sysdev/xics/icp-native.c. In other words, at this stage
we assume that the platform has a XICS interrupt controller and
we are using icp-native.c to drive it. Since the woken thread will
need to acknowledge and clear the IPI, we also export the base
physical address of the XICS registers using kvmppc_set_xics_phys()
for use in the low-level KVM book3s code.
When a vcpu is created, it is assigned to a virtual CPU core.
The vcore number is obtained by dividing the vcpu number by the
number of threads per core in the host. This number is exported
to userspace via the KVM_CAP_PPC_SMT capability. If qemu wishes
to run the guest in single-threaded mode, it should make all vcpu
numbers be multiples of the number of threads per core.
We distinguish three states of a vcpu: runnable (i.e., ready to execute
the guest), blocked (that is, idle), and busy in host. We currently
implement a policy that the vcore can run only when all its threads
are runnable or blocked. This way, if a vcpu needs to execute elsewhere
in the kernel or in qemu, it can do so without being starved of CPU
by the other vcpus.
When a vcore starts to run, it executes in the context of one of the
vcpu threads. The other vcpu threads all go to sleep and stay asleep
until something happens requiring the vcpu thread to return to qemu,
or to wake up to run the vcore (this can happen when another vcpu
thread goes from busy in host state to blocked).
It can happen that a vcpu goes from blocked to runnable state (e.g.
because of an interrupt), and the vcore it belongs to is already
running. In that case it can start to run immediately as long as
the none of the vcpus in the vcore have started to exit the guest.
We send the next free thread in the vcore an IPI to get it to start
to execute the guest. It synchronizes with the other threads via
the vcore->entry_exit_count field to make sure that it doesn't go
into the guest if the other vcpus are exiting by the time that it
is ready to actually enter the guest.
Note that there is no fixed relationship between the hardware thread
number and the vcpu number. Hardware threads are assigned to vcpus
as they become runnable, so we will always use the lower-numbered
hardware threads in preference to higher-numbered threads if not all
the vcpus in the vcore are runnable, regardless of which vcpus are
runnable.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:23:08 +04:00
rlwinm. r13 ,r13 ,4 7 - 3 1 ,3 0 ,3 1
beq 9 f
/* waking up from powersave (nap) state */
cmpwi c r1 ,r13 ,2
2011-01-24 10:42:41 +03:00
/ * Total l o s s o f H V s t a t e i s f a t a l , w e c o u l d t r y t o u s e t h e
* PIR t o l o c a t e a P A C A , t h e n u s e a n e m e r g e n c y s t a c k e t c . . .
* but f o r n o w , l e t ' s j u s t s t a y s t u c k h e r e
* /
KVM: PPC: Allow book3s_hv guests to use SMT processor modes
This lifts the restriction that book3s_hv guests can only run one
hardware thread per core, and allows them to use up to 4 threads
per core on POWER7. The host still has to run single-threaded.
This capability is advertised to qemu through a new KVM_CAP_PPC_SMT
capability. The return value of the ioctl querying this capability
is the number of vcpus per virtual CPU core (vcore), currently 4.
To use this, the host kernel should be booted with all threads
active, and then all the secondary threads should be offlined.
This will put the secondary threads into nap mode. KVM will then
wake them from nap mode and use them for running guest code (while
they are still offline). To wake the secondary threads, we send
them an IPI using a new xics_wake_cpu() function, implemented in
arch/powerpc/sysdev/xics/icp-native.c. In other words, at this stage
we assume that the platform has a XICS interrupt controller and
we are using icp-native.c to drive it. Since the woken thread will
need to acknowledge and clear the IPI, we also export the base
physical address of the XICS registers using kvmppc_set_xics_phys()
for use in the low-level KVM book3s code.
When a vcpu is created, it is assigned to a virtual CPU core.
The vcore number is obtained by dividing the vcpu number by the
number of threads per core in the host. This number is exported
to userspace via the KVM_CAP_PPC_SMT capability. If qemu wishes
to run the guest in single-threaded mode, it should make all vcpu
numbers be multiples of the number of threads per core.
We distinguish three states of a vcpu: runnable (i.e., ready to execute
the guest), blocked (that is, idle), and busy in host. We currently
implement a policy that the vcore can run only when all its threads
are runnable or blocked. This way, if a vcpu needs to execute elsewhere
in the kernel or in qemu, it can do so without being starved of CPU
by the other vcpus.
When a vcore starts to run, it executes in the context of one of the
vcpu threads. The other vcpu threads all go to sleep and stay asleep
until something happens requiring the vcpu thread to return to qemu,
or to wake up to run the vcore (this can happen when another vcpu
thread goes from busy in host state to blocked).
It can happen that a vcpu goes from blocked to runnable state (e.g.
because of an interrupt), and the vcore it belongs to is already
running. In that case it can start to run immediately as long as
the none of the vcpus in the vcore have started to exit the guest.
We send the next free thread in the vcore an IPI to get it to start
to execute the guest. It synchronizes with the other threads via
the vcore->entry_exit_count field to make sure that it doesn't go
into the guest if the other vcpus are exiting by the time that it
is ready to actually enter the guest.
Note that there is no fixed relationship between the hardware thread
number and the vcpu number. Hardware threads are assigned to vcpus
as they become runnable, so we will always use the lower-numbered
hardware threads in preference to higher-numbered threads if not all
the vcpus in the vcore are runnable, regardless of which vcpus are
runnable.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:23:08 +04:00
bgt c r1 ,.
GET_ P A C A ( r13 )
# ifdef C O N F I G _ K V M _ B O O K 3 S _ 6 4 _ H V
2012-02-03 04:54:17 +04:00
li r0 ,K V M _ H W T H R E A D _ I N _ K E R N E L
stb r0 ,H S T A T E _ H W T H R E A D _ S T A T E ( r13 )
/* Order setting hwthread_state vs. testing hwthread_req */
sync
lbz r0 ,H S T A T E _ H W T H R E A D _ R E Q ( r13 )
cmpwi r0 ,0
beq 1 f
KVM: PPC: Allow book3s_hv guests to use SMT processor modes
This lifts the restriction that book3s_hv guests can only run one
hardware thread per core, and allows them to use up to 4 threads
per core on POWER7. The host still has to run single-threaded.
This capability is advertised to qemu through a new KVM_CAP_PPC_SMT
capability. The return value of the ioctl querying this capability
is the number of vcpus per virtual CPU core (vcore), currently 4.
To use this, the host kernel should be booted with all threads
active, and then all the secondary threads should be offlined.
This will put the secondary threads into nap mode. KVM will then
wake them from nap mode and use them for running guest code (while
they are still offline). To wake the secondary threads, we send
them an IPI using a new xics_wake_cpu() function, implemented in
arch/powerpc/sysdev/xics/icp-native.c. In other words, at this stage
we assume that the platform has a XICS interrupt controller and
we are using icp-native.c to drive it. Since the woken thread will
need to acknowledge and clear the IPI, we also export the base
physical address of the XICS registers using kvmppc_set_xics_phys()
for use in the low-level KVM book3s code.
When a vcpu is created, it is assigned to a virtual CPU core.
The vcore number is obtained by dividing the vcpu number by the
number of threads per core in the host. This number is exported
to userspace via the KVM_CAP_PPC_SMT capability. If qemu wishes
to run the guest in single-threaded mode, it should make all vcpu
numbers be multiples of the number of threads per core.
We distinguish three states of a vcpu: runnable (i.e., ready to execute
the guest), blocked (that is, idle), and busy in host. We currently
implement a policy that the vcore can run only when all its threads
are runnable or blocked. This way, if a vcpu needs to execute elsewhere
in the kernel or in qemu, it can do so without being starved of CPU
by the other vcpus.
When a vcore starts to run, it executes in the context of one of the
vcpu threads. The other vcpu threads all go to sleep and stay asleep
until something happens requiring the vcpu thread to return to qemu,
or to wake up to run the vcore (this can happen when another vcpu
thread goes from busy in host state to blocked).
It can happen that a vcpu goes from blocked to runnable state (e.g.
because of an interrupt), and the vcore it belongs to is already
running. In that case it can start to run immediately as long as
the none of the vcpus in the vcore have started to exit the guest.
We send the next free thread in the vcore an IPI to get it to start
to execute the guest. It synchronizes with the other threads via
the vcore->entry_exit_count field to make sure that it doesn't go
into the guest if the other vcpus are exiting by the time that it
is ready to actually enter the guest.
Note that there is no fixed relationship between the hardware thread
number and the vcpu number. Hardware threads are assigned to vcpus
as they become runnable, so we will always use the lower-numbered
hardware threads in preference to higher-numbered threads if not all
the vcpus in the vcore are runnable, regardless of which vcpus are
runnable.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:23:08 +04:00
b k v m _ s t a r t _ g u e s t
1 :
# endif
beq c r1 ,2 f
b . p o w e r7 _ w a k e u p _ n o l o s s
2 : b . p o w e r7 _ w a k e u p _ l o s s
9 :
powerpc, KVM: Split HVMODE_206 cpu feature bit into separate HV and architecture bits
This replaces the single CPU_FTR_HVMODE_206 bit with two bits, one to
indicate that we have a usable hypervisor mode, and another to indicate
that the processor conforms to PowerISA version 2.06. We also add
another bit to indicate that the processor conforms to ISA version 2.01
and set that for PPC970 and derivatives.
Some PPC970 chips (specifically those in Apple machines) have a
hypervisor mode in that MSR[HV] is always 1, but the hypervisor mode
is not useful in the sense that there is no way to run any code in
supervisor mode (HV=0 PR=0). On these processors, the LPES0 and LPES1
bits in HID4 are always 0, and we use that as a way of detecting that
hypervisor mode is not useful.
Where we have a feature section in assembly code around code that
only applies on POWER7 in hypervisor mode, we use a construct like
END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
The definition of END_FTR_SECTION_IFSET is such that the code will
be enabled (not overwritten with nops) only if all bits in the
provided mask are set.
Note that the CPU feature check in __tlbie() only needs to check the
ARCH_206 bit, not the HVMODE bit, because __tlbie() can only get called
if we are running bare-metal, i.e. in hypervisor mode.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:26:11 +04:00
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ H V M O D E | C P U _ F T R _ A R C H _ 2 0 6 )
2011-01-24 10:42:41 +03:00
# endif / * C O N F I G _ P P C _ P 7 _ N A P * /
2011-06-29 04:18:26 +04:00
EXCEPTION_ P R O L O G _ P S E R I E S ( P A C A _ E X G E N , s y s t e m _ r e s e t _ c o m m o n , E X C _ S T D ,
NOTEST, 0 x10 0 )
2009-06-03 01:17:38 +04:00
. = 0 x2 0 0
2011-06-29 04:18:26 +04:00
machine_check_pSeries_1 :
/ * This i s m o v e d o u t o f l i n e a s i t c a n b e p a t c h e d b y F W , b u t
* some c o d e p a t h m i g h t s t i l l w a n t t o b r a n c h i n t o t h e o r i g i n a l
* vector
* /
b m a c h i n e _ c h e c k _ p S e r i e s
2009-06-03 01:17:38 +04:00
. = 0 x3 0 0
.globl data_access_pSeries
data_access_pSeries :
HMT_ M E D I U M
2011-04-05 07:59:58 +04:00
SET_ S C R A T C H 0 ( r13 )
2009-06-03 01:17:38 +04:00
BEGIN_ F T R _ S E C T I O N
2011-06-29 04:18:26 +04:00
b d a t a _ a c c e s s _ c h e c k _ s t a b
data_access_not_stab :
END_ M M U _ F T R _ S E C T I O N _ I F C L R ( M M U _ F T R _ S L B )
EXCEPTION_ P R O L O G _ P S E R I E S ( P A C A _ E X G E N , d a t a _ a c c e s s _ c o m m o n , E X C _ S T D ,
KVM: PPC: Implement MMIO emulation support for Book3S HV guests
This provides the low-level support for MMIO emulation in Book3S HV
guests. When the guest tries to map a page which is not covered by
any memslot, that page is taken to be an MMIO emulation page. Instead
of inserting a valid HPTE, we insert an HPTE that has the valid bit
clear but another hypervisor software-use bit set, which we call
HPTE_V_ABSENT, to indicate that this is an absent page. An
absent page is treated much like a valid page as far as guest hcalls
(H_ENTER, H_REMOVE, H_READ etc.) are concerned, except of course that
an absent HPTE doesn't need to be invalidated with tlbie since it
was never valid as far as the hardware is concerned.
When the guest accesses a page for which there is an absent HPTE, it
will take a hypervisor data storage interrupt (HDSI) since we now set
the VPM1 bit in the LPCR. Our HDSI handler for HPTE-not-present faults
looks up the hash table and if it finds an absent HPTE mapping the
requested virtual address, will switch to kernel mode and handle the
fault in kvmppc_book3s_hv_page_fault(), which at present just calls
kvmppc_hv_emulate_mmio() to set up the MMIO emulation.
This is based on an earlier patch by Benjamin Herrenschmidt, but since
heavily reworked.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-12 16:36:37 +04:00
KVMTEST, 0 x30 0 )
2009-06-03 01:17:38 +04:00
. = 0 x3 8 0
.globl data_access_slb_pSeries
data_access_slb_pSeries :
HMT_ M E D I U M
2011-04-05 07:59:58 +04:00
SET_ S C R A T C H 0 ( r13 )
KVM: PPC: Implement MMIO emulation support for Book3S HV guests
This provides the low-level support for MMIO emulation in Book3S HV
guests. When the guest tries to map a page which is not covered by
any memslot, that page is taken to be an MMIO emulation page. Instead
of inserting a valid HPTE, we insert an HPTE that has the valid bit
clear but another hypervisor software-use bit set, which we call
HPTE_V_ABSENT, to indicate that this is an absent page. An
absent page is treated much like a valid page as far as guest hcalls
(H_ENTER, H_REMOVE, H_READ etc.) are concerned, except of course that
an absent HPTE doesn't need to be invalidated with tlbie since it
was never valid as far as the hardware is concerned.
When the guest accesses a page for which there is an absent HPTE, it
will take a hypervisor data storage interrupt (HDSI) since we now set
the VPM1 bit in the LPCR. Our HDSI handler for HPTE-not-present faults
looks up the hash table and if it finds an absent HPTE mapping the
requested virtual address, will switch to kernel mode and handle the
fault in kvmppc_book3s_hv_page_fault(), which at present just calls
kvmppc_hv_emulate_mmio() to set up the MMIO emulation.
This is based on an earlier patch by Benjamin Herrenschmidt, but since
heavily reworked.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-12 16:36:37 +04:00
EXCEPTION_ P R O L O G _ 1 ( P A C A _ E X S L B , K V M T E S T , 0 x38 0 )
2009-06-03 01:17:38 +04:00
std r3 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
mfspr r3 ,S P R N _ D A R
# ifdef _ _ D I S A B L E D _ _
/* Keep that around for when we re-implement dynamic VSIDs */
cmpdi r3 ,0
bge s l b _ m i s s _ u s e r _ p s e r i e s
# endif / * _ _ D I S A B L E D _ _ * /
2011-06-29 04:18:26 +04:00
mfspr r12 ,S P R N _ S R R 1
2009-06-03 01:17:38 +04:00
# ifndef C O N F I G _ R E L O C A T A B L E
b . s l b _ m i s s _ r e a l m o d e
# else
/ *
* We c a n ' t j u s t u s e a d i r e c t b r a n c h t o . s l b _ m i s s _ r e a l m o d e
* because t h e d i s t a n c e f r o m h e r e t o t h e r e d e p e n d s o n w h e r e
* the k e r n e l e n d s u p b e i n g p u t .
* /
mfctr r11
ld r10 ,P A C A K B A S E ( r13 )
LOAD_ H A N D L E R ( r10 , . s l b _ m i s s _ r e a l m o d e )
mtctr r10
bctr
# endif
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x40 0 , 0 x40 0 , i n s t r u c t i o n _ a c c e s s )
2009-06-03 01:17:38 +04:00
. = 0 x4 8 0
.globl instruction_access_slb_pSeries
instruction_access_slb_pSeries :
HMT_ M E D I U M
2011-04-05 07:59:58 +04:00
SET_ S C R A T C H 0 ( r13 )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
EXCEPTION_ P R O L O G _ 1 ( P A C A _ E X S L B , K V M T E S T _ P R , 0 x48 0 )
2009-06-03 01:17:38 +04:00
std r3 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
mfspr r3 ,S P R N _ S R R 0 / * S R R 0 i s f a u l t i n g a d d r e s s * /
# ifdef _ _ D I S A B L E D _ _
/* Keep that around for when we re-implement dynamic VSIDs */
cmpdi r3 ,0
bge s l b _ m i s s _ u s e r _ p s e r i e s
# endif / * _ _ D I S A B L E D _ _ * /
2011-06-29 04:18:26 +04:00
mfspr r12 ,S P R N _ S R R 1
2009-06-03 01:17:38 +04:00
# ifndef C O N F I G _ R E L O C A T A B L E
b . s l b _ m i s s _ r e a l m o d e
# else
mfctr r11
ld r10 ,P A C A K B A S E ( r13 )
LOAD_ H A N D L E R ( r10 , . s l b _ m i s s _ r e a l m o d e )
mtctr r10
bctr
# endif
2011-04-05 08:27:11 +04:00
/ * We o p e n c o d e t h e s e a s w e c a n ' t h a v e a " . = x " ( e v e n w i t h
* x = " . " w i t h i n a f e a t u r e s e c t i o n
* /
2011-04-05 08:20:31 +04:00
. = 0 x5 0 0 ;
2011-04-05 08:27:11 +04:00
.globl hardware_ i n t e r r u p t _ p S e r i e s ;
.globl hardware_ i n t e r r u p t _ h v ;
2011-04-05 08:20:31 +04:00
hardware_interrupt_pSeries :
2011-04-05 08:27:11 +04:00
hardware_interrupt_hv :
2011-04-05 08:20:31 +04:00
BEGIN_ F T R _ S E C T I O N
2011-06-29 04:18:26 +04:00
_ MASKABLE_ E X C E P T I O N _ P S E R I E S ( 0 x50 2 , h a r d w a r e _ i n t e r r u p t ,
EXC_ H V , S O F T E N _ T E S T _ H V )
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x50 2 )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
FTR_ S E C T I O N _ E L S E
_ MASKABLE_ E X C E P T I O N _ P S E R I E S ( 0 x50 0 , h a r d w a r e _ i n t e r r u p t ,
KVM: PPC: book3s_hv: Add support for PPC970-family processors
This adds support for running KVM guests in supervisor mode on those
PPC970 processors that have a usable hypervisor mode. Unfortunately,
Apple G5 machines have supervisor mode disabled (MSR[HV] is forced to
1), but the YDL PowerStation does have a usable hypervisor mode.
There are several differences between the PPC970 and POWER7 in how
guests are managed. These differences are accommodated using the
CPU_FTR_ARCH_201 (PPC970) and CPU_FTR_ARCH_206 (POWER7) CPU feature
bits. Notably, on PPC970:
* The LPCR, LPID or RMOR registers don't exist, and the functions of
those registers are provided by bits in HID4 and one bit in HID0.
* External interrupts can be directed to the hypervisor, but unlike
POWER7 they are masked by MSR[EE] in non-hypervisor modes and use
SRR0/1 not HSRR0/1.
* There is no virtual RMA (VRMA) mode; the guest must use an RMO
(real mode offset) area.
* The TLB entries are not tagged with the LPID, so it is necessary to
flush the whole TLB on partition switch. Furthermore, when switching
partitions we have to ensure that no other CPU is executing the tlbie
or tlbsync instructions in either the old or the new partition,
otherwise undefined behaviour can occur.
* The PMU has 8 counters (PMC registers) rather than 6.
* The DSCR, PURR, SPURR, AMR, AMOR, UAMOR registers don't exist.
* The SLB has 64 entries rather than 32.
* There is no mediated external interrupt facility, so if we switch to
a guest that has a virtual external interrupt pending but the guest
has MSR[EE] = 0, we have to arrange to have an interrupt pending for
it so that we can get control back once it re-enables interrupts. We
do that by sending ourselves an IPI with smp_send_reschedule after
hard-disabling interrupts.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:40:08 +04:00
EXC_ S T D , S O F T E N _ T E S T _ H V _ 2 0 1 )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ S T D , 0 x50 0 )
powerpc, KVM: Split HVMODE_206 cpu feature bit into separate HV and architecture bits
This replaces the single CPU_FTR_HVMODE_206 bit with two bits, one to
indicate that we have a usable hypervisor mode, and another to indicate
that the processor conforms to PowerISA version 2.06. We also add
another bit to indicate that the processor conforms to ISA version 2.01
and set that for PPC970 and derivatives.
Some PPC970 chips (specifically those in Apple machines) have a
hypervisor mode in that MSR[HV] is always 1, but the hypervisor mode
is not useful in the sense that there is no way to run any code in
supervisor mode (HV=0 PR=0). On these processors, the LPES0 and LPES1
bits in HID4 are always 0, and we use that as a way of detecting that
hypervisor mode is not useful.
Where we have a feature section in assembly code around code that
only applies on POWER7 in hypervisor mode, we use a construct like
END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
The definition of END_FTR_SECTION_IFSET is such that the code will
be enabled (not overwritten with nops) only if all bits in the
provided mask are set.
Note that the CPU feature check in __tlbie() only needs to check the
ARCH_206 bit, not the HVMODE bit, because __tlbie() can only get called
if we are running bare-metal, i.e. in hypervisor mode.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:26:11 +04:00
ALT_ F T R _ S E C T I O N _ E N D _ I F S E T ( C P U _ F T R _ H V M O D E | C P U _ F T R _ A R C H _ 2 0 6 )
2011-04-05 08:20:31 +04:00
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x60 0 , 0 x60 0 , a l i g n m e n t )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x60 0 )
2011-06-29 04:18:26 +04:00
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x70 0 , 0 x70 0 , p r o g r a m _ c h e c k )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x70 0 )
2011-06-29 04:18:26 +04:00
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x80 0 , 0 x80 0 , f p _ u n a v a i l a b l e )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x80 0 )
2011-04-05 08:20:31 +04:00
2011-04-05 08:27:11 +04:00
MASKABLE_ E X C E P T I O N _ P S E R I E S ( 0 x90 0 , 0 x90 0 , d e c r e m e n t e r )
2012-07-26 17:56:11 +04:00
STD_ E X C E P T I O N _ H V ( 0 x98 0 , 0 x98 2 , h d e c r e m e n t e r )
2011-04-05 08:20:31 +04:00
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x a00 , 0 x a00 , t r a p _ 0 a )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x a00 )
2011-06-29 04:18:26 +04:00
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x b00 , 0 x b00 , t r a p _ 0 b )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x b00 )
2009-06-03 01:17:38 +04:00
. = 0 xc0 0
.globl system_call_pSeries
system_call_pSeries :
HMT_ M E D I U M
2011-06-29 04:18:26 +04:00
# ifdef C O N F I G _ K V M _ B O O K 3 S _ 6 4 _ H A N D L E R
SET_ S C R A T C H 0 ( r13 )
GET_ P A C A ( r13 )
std r9 ,P A C A _ E X G E N + E X _ R 9 ( r13 )
std r10 ,P A C A _ E X G E N + E X _ R 1 0 ( r13 )
mfcr r9
KVMTEST( 0 x c00 )
GET_ S C R A T C H 0 ( r13 )
# endif
2012-11-02 10:16:01 +04:00
SYSCALL_ P S E R I E S _ 1
SYSCALL_ P S E R I E S _ 2 _ R F I D
SYSCALL_ P S E R I E S _ 3
2011-06-29 04:18:26 +04:00
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ S T D , 0 x c00 )
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x d00 , 0 x d00 , s i n g l e _ s t e p )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x d00 )
2011-04-05 08:27:11 +04:00
/ * At 0 x e ? ? ? w e h a v e a b u n c h o f h y p e r v i s o r e x c e p t i o n s , w e b r a n c h
* out o f l i n e t o h a n d l e t h e m
* /
. = 0 xe0 0
2012-07-04 00:29:41 +04:00
hv_exception_trampoline :
2011-04-05 08:27:11 +04:00
b h _ d a t a _ s t o r a g e _ h v
. = 0 xe2 0
b h _ i n s t r _ s t o r a g e _ h v
. = 0 xe4 0
b e m u l a t i o n _ a s s i s t _ h v
. = 0 xe5 0
b h m i _ e x c e p t i o n _ h v
. = 0 xe6 0
b h m i _ e x c e p t i o n _ h v
2009-06-03 01:17:38 +04:00
/ * We n e e d t o d e a l w i t h t h e A l t i v e c u n a v a i l a b l e e x c e p t i o n
* here w h i c h i s a t 0 x f20 , t h u s i n t h e m i d d l e o f t h e
* prolog c o d e o f t h e P e r f o r m a n c e M o n i t o r o n e . A l i t t l e
* trickery i s t h u s n e c e s s a r y
* /
2009-10-18 05:24:06 +04:00
performance_monitor_pSeries_1 :
2009-06-03 01:17:38 +04:00
. = 0 xf0 0
b p e r f o r m a n c e _ m o n i t o r _ p S e r i e s
2009-10-18 05:24:06 +04:00
altivec_unavailable_pSeries_1 :
2009-06-03 01:17:38 +04:00
. = 0 xf2 0
b a l t i v e c _ u n a v a i l a b l e _ p S e r i e s
2009-10-18 05:24:06 +04:00
vsx_unavailable_pSeries_1 :
2009-06-03 01:17:38 +04:00
. = 0 xf4 0
b v s x _ u n a v a i l a b l e _ p S e r i e s
# ifdef C O N F I G _ C B E _ R A S
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ H V ( 0 x12 0 0 , 0 x12 0 2 , c b e _ s y s t e m _ e r r o r )
2011-09-13 08:15:31 +04:00
KVM_ H A N D L E R _ S K I P ( P A C A _ E X G E N , E X C _ H V , 0 x12 0 2 )
2009-06-03 01:17:38 +04:00
# endif / * C O N F I G _ C B E _ R A S * /
2011-06-29 04:18:26 +04:00
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x13 0 0 , 0 x13 0 0 , i n s t r u c t i o n _ b r e a k p o i n t )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R _ S K I P ( P A C A _ E X G E N , E X C _ S T D , 0 x13 0 0 )
2011-06-29 04:18:26 +04:00
2012-09-10 04:35:26 +04:00
. = 0 x1 5 0 0
2012-10-31 22:58:36 +04:00
.global denorm_exception_hv
2012-09-10 04:35:26 +04:00
denorm_exception_hv :
HMT_ M E D I U M
mtspr S P R N _ S P R G _ H S C R A T C H 0 ,r13
mfspr r13 ,S P R N _ S P R G _ H P A C A
std r9 ,P A C A _ E X G E N + E X _ R 9 ( r13 )
std r10 ,P A C A _ E X G E N + E X _ R 1 0 ( r13 )
std r11 ,P A C A _ E X G E N + E X _ R 1 1 ( r13 )
std r12 ,P A C A _ E X G E N + E X _ R 1 2 ( r13 )
mfspr r9 ,S P R N _ S P R G _ H S C R A T C H 0
std r9 ,P A C A _ E X G E N + E X _ R 1 3 ( r13 )
mfcr r9
# ifdef C O N F I G _ P P C _ D E N O R M A L I S A T I O N
mfspr r10 ,S P R N _ H S R R 1
mfspr r11 ,S P R N _ H S R R 0 / * s a v e H S R R 0 * /
andis. r10 ,r10 ,( H S R R 1 _ D E N O R M ) @h /* denorm? */
addi r11 ,r11 ,- 4 / * H S R R 0 i s n e x t i n s t r u c t i o n * /
bne+ d e n o r m _ a s s i s t
# endif
EXCEPTION_ P R O L O G _ P S E R I E S _ 1 ( d e n o r m _ c o m m o n , E X C _ H V )
KVM_ H A N D L E R _ S K I P ( P A C A _ E X G E N , E X C _ S T D , 0 x15 0 0 )
2009-06-03 01:17:38 +04:00
# ifdef C O N F I G _ C B E _ R A S
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ H V ( 0 x16 0 0 , 0 x16 0 2 , c b e _ m a i n t e n a n c e )
2011-09-13 08:15:31 +04:00
KVM_ H A N D L E R _ S K I P ( P A C A _ E X G E N , E X C _ H V , 0 x16 0 2 )
2009-06-03 01:17:38 +04:00
# endif / * C O N F I G _ C B E _ R A S * /
2011-06-29 04:18:26 +04:00
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( 0 x17 0 0 , 0 x17 0 0 , a l t i v e c _ a s s i s t )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x17 0 0 )
2011-06-29 04:18:26 +04:00
2009-06-03 01:17:38 +04:00
# ifdef C O N F I G _ C B E _ R A S
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ H V ( 0 x18 0 0 , 0 x18 0 2 , c b e _ t h e r m a l )
2011-09-13 08:15:31 +04:00
KVM_ H A N D L E R _ S K I P ( P A C A _ E X G E N , E X C _ H V , 0 x18 0 2 )
2012-11-02 06:53:36 +04:00
# else
. = 0 x1 8 0 0
2009-06-03 01:17:38 +04:00
# endif / * C O N F I G _ C B E _ R A S * /
2011-04-05 08:27:11 +04:00
/*** Out of line interrupts support ***/
2012-11-02 06:53:36 +04:00
.align 7
2011-06-29 04:18:26 +04:00
/* moved from 0x200 */
machine_check_pSeries :
.globl machine_check_fwnmi
machine_check_fwnmi :
HMT_ M E D I U M
SET_ S C R A T C H 0 ( r13 ) / * s a v e r13 * /
EXCEPTION_ P R O L O G _ P S E R I E S ( P A C A _ E X M C , m a c h i n e _ c h e c k _ c o m m o n ,
EXC_ S T D , K V M T E S T , 0 x20 0 )
KVM_ H A N D L E R _ S K I P ( P A C A _ E X M C , E X C _ S T D , 0 x20 0 )
/* moved from 0x300 */
data_access_check_stab :
GET_ P A C A ( r13 )
std r9 ,P A C A _ E X S L B + E X _ R 9 ( r13 )
std r10 ,P A C A _ E X S L B + E X _ R 1 0 ( r13 )
mfspr r10 ,S P R N _ D A R
mfspr r9 ,S P R N _ D S I S R
srdi r10 ,r10 ,6 0
rlwimi r10 ,r9 ,1 6 ,0 x20
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
# ifdef C O N F I G _ K V M _ B O O K 3 S _ P R
2011-06-29 04:20:58 +04:00
lbz r9 ,H S T A T E _ I N _ G U E S T ( r13 )
2011-06-29 04:18:26 +04:00
rlwimi r10 ,r9 ,8 ,0 x30 0
# endif
mfcr r9
cmpwi r10 ,0 x2 c
beq d o _ s t a b _ b o l t e d _ p S e r i e s
mtcrf 0 x80 ,r9
ld r9 ,P A C A _ E X S L B + E X _ R 9 ( r13 )
ld r10 ,P A C A _ E X S L B + E X _ R 1 0 ( r13 )
b d a t a _ a c c e s s _ n o t _ s t a b
do_stab_bolted_pSeries :
std r11 ,P A C A _ E X S L B + E X _ R 1 1 ( r13 )
std r12 ,P A C A _ E X S L B + E X _ R 1 2 ( r13 )
GET_ S C R A T C H 0 ( r10 )
std r10 ,P A C A _ E X S L B + E X _ R 1 3 ( r13 )
EXCEPTION_ P R O L O G _ P S E R I E S _ 1 ( . d o _ s t a b _ b o l t e d , E X C _ S T D )
KVM: PPC: Implement MMIO emulation support for Book3S HV guests
This provides the low-level support for MMIO emulation in Book3S HV
guests. When the guest tries to map a page which is not covered by
any memslot, that page is taken to be an MMIO emulation page. Instead
of inserting a valid HPTE, we insert an HPTE that has the valid bit
clear but another hypervisor software-use bit set, which we call
HPTE_V_ABSENT, to indicate that this is an absent page. An
absent page is treated much like a valid page as far as guest hcalls
(H_ENTER, H_REMOVE, H_READ etc.) are concerned, except of course that
an absent HPTE doesn't need to be invalidated with tlbie since it
was never valid as far as the hardware is concerned.
When the guest accesses a page for which there is an absent HPTE, it
will take a hypervisor data storage interrupt (HDSI) since we now set
the VPM1 bit in the LPCR. Our HDSI handler for HPTE-not-present faults
looks up the hash table and if it finds an absent HPTE mapping the
requested virtual address, will switch to kernel mode and handle the
fault in kvmppc_book3s_hv_page_fault(), which at present just calls
kvmppc_hv_emulate_mmio() to set up the MMIO emulation.
This is based on an earlier patch by Benjamin Herrenschmidt, but since
heavily reworked.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-12 16:36:37 +04:00
KVM_ H A N D L E R _ S K I P ( P A C A _ E X G E N , E X C _ S T D , 0 x30 0 )
KVM_ H A N D L E R _ S K I P ( P A C A _ E X S L B , E X C _ S T D , 0 x38 0 )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x40 0 )
KVM_ H A N D L E R _ P R ( P A C A _ E X S L B , E X C _ S T D , 0 x48 0 )
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x90 0 )
2011-06-29 04:18:26 +04:00
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x98 2 )
2012-09-10 04:35:26 +04:00
# ifdef C O N F I G _ P P C _ D E N O R M A L I S A T I O N
denorm_assist :
BEGIN_ F T R _ S E C T I O N
/ *
* To d e n o r m a l i s e w e n e e d t o m o v e a c o p y o f t h e r e g i s t e r t o i t s e l f .
* For P O W E R 6 d o t h a t h e r e f o r a l l F P r e g s .
* /
mfmsr r10
ori r10 ,r10 ,( M S R _ F P | M S R _ F E 0 | M S R _ F E 1 )
xori r10 ,r10 ,( M S R _ F E 0 | M S R _ F E 1 )
mtmsrd r10
sync
fmr 0 ,0
fmr 1 ,1
fmr 2 ,2
fmr 3 ,3
fmr 4 ,4
fmr 5 ,5
fmr 6 ,6
fmr 7 ,7
fmr 8 ,8
fmr 9 ,9
fmr 1 0 ,1 0
fmr 1 1 ,1 1
fmr 1 2 ,1 2
fmr 1 3 ,1 3
fmr 1 4 ,1 4
fmr 1 5 ,1 5
fmr 1 6 ,1 6
fmr 1 7 ,1 7
fmr 1 8 ,1 8
fmr 1 9 ,1 9
fmr 2 0 ,2 0
fmr 2 1 ,2 1
fmr 2 2 ,2 2
fmr 2 3 ,2 3
fmr 2 4 ,2 4
fmr 2 5 ,2 5
fmr 2 6 ,2 6
fmr 2 7 ,2 7
fmr 2 8 ,2 8
fmr 2 9 ,2 9
fmr 3 0 ,3 0
fmr 3 1 ,3 1
FTR_ S E C T I O N _ E L S E
/ *
* To d e n o r m a l i s e w e n e e d t o m o v e a c o p y o f t h e r e g i s t e r t o i t s e l f .
* For P O W E R 7 d o t h a t h e r e f o r t h e f i r s t 3 2 V S X r e g i s t e r s o n l y .
* /
mfmsr r10
oris r10 ,r10 ,M S R _ V S X @h
mtmsrd r10
sync
XVCPSGNDP( 0 ,0 ,0 )
XVCPSGNDP( 1 ,1 ,1 )
XVCPSGNDP( 2 ,2 ,2 )
XVCPSGNDP( 3 ,3 ,3 )
XVCPSGNDP( 4 ,4 ,4 )
XVCPSGNDP( 5 ,5 ,5 )
XVCPSGNDP( 6 ,6 ,6 )
XVCPSGNDP( 7 ,7 ,7 )
XVCPSGNDP( 8 ,8 ,8 )
XVCPSGNDP( 9 ,9 ,9 )
XVCPSGNDP( 1 0 ,1 0 ,1 0 )
XVCPSGNDP( 1 1 ,1 1 ,1 1 )
XVCPSGNDP( 1 2 ,1 2 ,1 2 )
XVCPSGNDP( 1 3 ,1 3 ,1 3 )
XVCPSGNDP( 1 4 ,1 4 ,1 4 )
XVCPSGNDP( 1 5 ,1 5 ,1 5 )
XVCPSGNDP( 1 6 ,1 6 ,1 6 )
XVCPSGNDP( 1 7 ,1 7 ,1 7 )
XVCPSGNDP( 1 8 ,1 8 ,1 8 )
XVCPSGNDP( 1 9 ,1 9 ,1 9 )
XVCPSGNDP( 2 0 ,2 0 ,2 0 )
XVCPSGNDP( 2 1 ,2 1 ,2 1 )
XVCPSGNDP( 2 2 ,2 2 ,2 2 )
XVCPSGNDP( 2 3 ,2 3 ,2 3 )
XVCPSGNDP( 2 4 ,2 4 ,2 4 )
XVCPSGNDP( 2 5 ,2 5 ,2 5 )
XVCPSGNDP( 2 6 ,2 6 ,2 6 )
XVCPSGNDP( 2 7 ,2 7 ,2 7 )
XVCPSGNDP( 2 8 ,2 8 ,2 8 )
XVCPSGNDP( 2 9 ,2 9 ,2 9 )
XVCPSGNDP( 3 0 ,3 0 ,3 0 )
XVCPSGNDP( 3 1 ,3 1 ,3 1 )
ALT_ F T R _ S E C T I O N _ E N D _ I F C L R ( C P U _ F T R _ A R C H _ 2 0 6 )
mtspr S P R N _ H S R R 0 ,r11
mtcrf 0 x80 ,r9
ld r9 ,P A C A _ E X G E N + E X _ R 9 ( r13 )
ld r10 ,P A C A _ E X G E N + E X _ R 1 0 ( r13 )
ld r11 ,P A C A _ E X G E N + E X _ R 1 1 ( r13 )
ld r12 ,P A C A _ E X G E N + E X _ R 1 2 ( r13 )
ld r13 ,P A C A _ E X G E N + E X _ R 1 3 ( r13 )
HRFID
b .
# endif
2011-06-29 04:18:26 +04:00
.align 7
2011-04-05 08:27:11 +04:00
/* moved from 0xe00 */
2011-06-29 04:18:26 +04:00
STD_ E X C E P T I O N _ H V ( . , 0 x e 0 2 , h _ d a t a _ s t o r a g e )
KVM_ H A N D L E R _ S K I P ( P A C A _ E X G E N , E X C _ H V , 0 x e 0 2 )
STD_ E X C E P T I O N _ H V ( . , 0 x e 2 2 , h _ i n s t r _ s t o r a g e )
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x e 2 2 )
STD_ E X C E P T I O N _ H V ( . , 0 x e 4 2 , e m u l a t i o n _ a s s i s t )
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x e 4 2 )
STD_ E X C E P T I O N _ H V ( . , 0 x e 6 2 , h m i _ e x c e p t i o n ) / * n e e d t o f l u s h c a c h e ? * /
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x e 6 2 )
2009-06-03 01:17:38 +04:00
/* moved from 0xf00 */
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( . , 0 x f00 , p e r f o r m a n c e _ m o n i t o r )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x f00 )
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( . , 0 x f20 , a l t i v e c _ u n a v a i l a b l e )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x f20 )
2011-04-05 08:27:11 +04:00
STD_ E X C E P T I O N _ P S E R I E S ( . , 0 x f40 , v s x _ u n a v a i l a b l e )
KVM: PPC: Add support for Book3S processors in hypervisor mode
This adds support for KVM running on 64-bit Book 3S processors,
specifically POWER7, in hypervisor mode. Using hypervisor mode means
that the guest can use the processor's supervisor mode. That means
that the guest can execute privileged instructions and access privileged
registers itself without trapping to the host. This gives excellent
performance, but does mean that KVM cannot emulate a processor
architecture other than the one that the hardware implements.
This code assumes that the guest is running paravirtualized using the
PAPR (Power Architecture Platform Requirements) interface, which is the
interface that IBM's PowerVM hypervisor uses. That means that existing
Linux distributions that run on IBM pSeries machines will also run
under KVM without modification. In order to communicate the PAPR
hypercalls to qemu, this adds a new KVM_EXIT_PAPR_HCALL exit code
to include/linux/kvm.h.
Currently the choice between book3s_hv support and book3s_pr support
(i.e. the existing code, which runs the guest in user mode) has to be
made at kernel configuration time, so a given kernel binary can only
do one or the other.
This new book3s_hv code doesn't support MMIO emulation at present.
Since we are running paravirtualized guests, this isn't a serious
restriction.
With the guest running in supervisor mode, most exceptions go straight
to the guest. We will never get data or instruction storage or segment
interrupts, alignment interrupts, decrementer interrupts, program
interrupts, single-step interrupts, etc., coming to the hypervisor from
the guest. Therefore this introduces a new KVMTEST_NONHV macro for the
exception entry path so that we don't have to do the KVM test on entry
to those exception handlers.
We do however get hypervisor decrementer, hypervisor data storage,
hypervisor instruction storage, and hypervisor emulation assist
interrupts, so we have to handle those.
In hypervisor mode, real-mode accesses can access all of RAM, not just
a limited amount. Therefore we put all the guest state in the vcpu.arch
and use the shadow_vcpu in the PACA only for temporary scratch space.
We allocate the vcpu with kzalloc rather than vzalloc, and we don't use
anything in the kvmppc_vcpu_book3s struct, so we don't allocate it.
We don't have a shared page with the guest, but we still need a
kvm_vcpu_arch_shared struct to store the values of various registers,
so we include one in the vcpu_arch struct.
The POWER7 processor has a restriction that all threads in a core have
to be in the same partition. MMU-on kernel code counts as a partition
(partition 0), so we have to do a partition switch on every entry to and
exit from the guest. At present we require the host and guest to run
in single-thread mode because of this hardware restriction.
This code allocates a hashed page table for the guest and initializes
it with HPTEs for the guest's Virtual Real Memory Area (VRMA). We
require that the guest memory is allocated using 16MB huge pages, in
order to simplify the low-level memory management. This also means that
we can get away without tracking paging activity in the host for now,
since huge pages can't be paged or swapped.
This also adds a few new exports needed by the book3s_hv code.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 04:21:34 +04:00
KVM_ H A N D L E R _ P R ( P A C A _ E X G E N , E X C _ S T D , 0 x f40 )
2009-06-03 01:17:38 +04:00
/ *
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
* An i n t e r r u p t c a m e i n w h i l e s o f t - d i s a b l e d . W e s e t p a c a - > i r q _ h a p p e n e d ,
* then, i f i t w a s a d e c r e m e n t e r i n t e r r u p t , w e b u m p t h e d e c t o m a x a n d
* and r e t u r n , e l s e w e h a r d d i s a b l e a n d r e t u r n . T h i s i s c a l l e d w i t h
* r1 0 c o n t a i n i n g t h e v a l u e t o O R t o t h e p a c a f i e l d .
2009-06-03 01:17:38 +04:00
* /
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
# define M A S K E D _ I N T E R R U P T ( _ H ) \
masked_ ## _ H # # i n t e r r u p t : \
std r11 ,P A C A _ E X G E N + E X _ R 1 1 ( r13 ) ; \
lbz r11 ,P A C A I R Q H A P P E N E D ( r13 ) ; \
or r11 ,r11 ,r10 ; \
stb r11 ,P A C A I R Q H A P P E N E D ( r13 ) ; \
andi. r10 ,r10 ,P A C A _ I R Q _ D E C ; \
beq 1 f ; \
lis r10 ,0 x7 f f f ; \
ori r10 ,r10 ,0 x f f f f ; \
mtspr S P R N _ D E C ,r10 ; \
b 2 f ; \
1 : mfspr r10 ,S P R N _ ## _ H # # S R R 1 ; \
rldicl r10 ,r10 ,4 8 ,1 ; /* clear MSR_EE */ \
rotldi r10 ,r10 ,1 6 ; \
mtspr S P R N _ ## _ H # # S R R 1 ,r10 ; \
2 : mtcrf 0 x80 ,r9 ; \
ld r9 ,P A C A _ E X G E N + E X _ R 9 ( r13 ) ; \
ld r10 ,P A C A _ E X G E N + E X _ R 1 0 ( r13 ) ; \
ld r11 ,P A C A _ E X G E N + E X _ R 1 1 ( r13 ) ; \
GET_ S C R A T C H 0 ( r13 ) ; \
# # _ H## r f i d ; \
2009-06-03 01:17:38 +04:00
b .
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
MASKED_ I N T E R R U P T ( )
MASKED_ I N T E R R U P T ( H )
2009-06-03 01:17:38 +04:00
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
/ *
* Called f r o m a r c h _ l o c a l _ i r q _ e n a b l e w h e n a n i n t e r r u p t n e e d s
* to b e r e s e n t . r3 c o n t a i n s 0 x50 0 o r 0 x90 0 t o i n d i c a t e w h i c h
* kind o f i n t e r r u p t . M S R : E E i s a l r e a d y o f f . W e g e n e r a t e a
* stackframe l i k e i f a r e a l i n t e r r u p t h a d h a p p e n e d .
*
* Note : While M S R : E E i s o f f , w e n e e d t o m a k e s u r e t h a t _ M S R
* in t h e g e n e r a t e d f r a m e h a s E E s e t t o 1 o r t h e e x c e p t i o n
* handler w i l l n o t p r o p e r l y r e - e n a b l e t h e m .
* /
_ GLOBAL( _ _ r e p l a y _ i n t e r r u p t )
/ * We a r e g o i n g t o j u m p t o t h e e x c e p t i o n c o m m o n c o d e w h i c h
* will r e t r i e v e v a r i o u s r e g i s t e r v a l u e s f r o m t h e P A C A w h i c h
* we d o n ' t g i v e a d a m n a b o u t , s o w e d o n ' t b o t h e r s t o r i n g t h e m .
* /
mfmsr r12
mflr r11
mfcr r9
ori r12 ,r12 ,M S R _ E E
andi. r3 ,r3 ,0 x08 0 0
bne d e c r e m e n t e r _ c o m m o n
b h a r d w a r e _ i n t e r r u p t _ c o m m o n
2011-04-05 08:20:31 +04:00
2009-06-03 01:17:38 +04:00
# ifdef C O N F I G _ P P C _ P S E R I E S
/ *
* Vectors f o r t h e F W N M I o p t i o n . S h a r e c o m m o n c o d e .
* /
.globl system_reset_fwnmi
.align 7
system_reset_fwnmi :
HMT_ M E D I U M
2011-04-05 07:59:58 +04:00
SET_ S C R A T C H 0 ( r13 ) / * s a v e r13 * /
2011-06-29 04:18:26 +04:00
EXCEPTION_ P R O L O G _ P S E R I E S ( P A C A _ E X G E N , s y s t e m _ r e s e t _ c o m m o n , E X C _ S T D ,
NOTEST, 0 x10 0 )
2009-06-03 01:17:38 +04:00
# endif / * C O N F I G _ P P C _ P S E R I E S * /
# ifdef _ _ D I S A B L E D _ _
/ *
* This i s u s e d f o r w h e n t h e S L B m i s s h a n d l e r h a s t o g o v i r t u a l ,
* which d o e s n ' t h a p p e n f o r n o w a n y m o r e b u t w i l l o n c e w e r e - i m p l e m e n t
* dynamic V S I D s f o r s h a r e d p a g e t a b l e s
* /
slb_miss_user_pseries :
std r10 ,P A C A _ E X G E N + E X _ R 1 0 ( r13 )
std r11 ,P A C A _ E X G E N + E X _ R 1 1 ( r13 )
std r12 ,P A C A _ E X G E N + E X _ R 1 2 ( r13 )
2011-04-05 07:59:58 +04:00
GET_ S C R A T C H 0 ( r10 )
2009-06-03 01:17:38 +04:00
ld r11 ,P A C A _ E X S L B + E X _ R 9 ( r13 )
ld r12 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
std r10 ,P A C A _ E X G E N + E X _ R 1 3 ( r13 )
std r11 ,P A C A _ E X G E N + E X _ R 9 ( r13 )
std r12 ,P A C A _ E X G E N + E X _ R 3 ( r13 )
clrrdi r12 ,r13 ,3 2
mfmsr r10
mfspr r11 ,S R R 0 / * s a v e S R R 0 * /
ori r12 ,r12 ,s l b _ m i s s _ u s e r _ c o m m o n @l /* virt addr of handler */
ori r10 ,r10 ,M S R _ I R | M S R _ D R | M S R _ R I
mtspr S R R 0 ,r12
mfspr r12 ,S R R 1 / * a n d S R R 1 * /
mtspr S R R 1 ,r10
rfid
b . / * p r e v e n t s p e c . e x e c u t i o n * /
# endif / * _ _ D I S A B L E D _ _ * /
/ *
* Code f r o m h e r e d o w n t o _ _ e n d _ h a n d l e r s i s i n v o k e d f r o m t h e
* exception p r o l o g s a b o v e . B e c a u s e t h e p r o l o g s a s s e m b l e t h e
* addresses o f t h e s e h a n d l e r s u s i n g t h e L O A D _ H A N D L E R m a c r o ,
2012-11-05 10:10:35 +04:00
* which u s e s a n o r i i n s t r u c t i o n , t h e s e h a n d l e r s m u s t b e i n
* the f i r s t 6 4 k o f t h e k e r n e l i m a g e .
2009-06-03 01:17:38 +04:00
* /
/*** Common interrupt handlers ***/
STD_ E X C E P T I O N _ C O M M O N ( 0 x10 0 , s y s t e m _ r e s e t , . s y s t e m _ r e s e t _ e x c e p t i o n )
/ *
* Machine c h e c k i s d i f f e r e n t b e c a u s e w e u s e a d i f f e r e n t
* save a r e a : P A C A _ E X M C i n s t e a d o f P A C A _ E X G E N .
* /
.align 7
.globl machine_check_common
machine_check_common :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x20 0 , P A C A _ E X M C )
FINISH_ N A P
DISABLE_ I N T S
bl . s a v e _ n v g p r s
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . m a c h i n e _ c h e c k _ e x c e p t i o n
b . r e t _ f r o m _ e x c e p t
2012-03-01 03:52:01 +04:00
STD_ E X C E P T I O N _ C O M M O N _ A S Y N C ( 0 x50 0 , h a r d w a r e _ i n t e r r u p t , d o _ I R Q )
STD_ E X C E P T I O N _ C O M M O N _ A S Y N C ( 0 x90 0 , d e c r e m e n t e r , . t i m e r _ i n t e r r u p t )
2012-07-26 17:56:11 +04:00
STD_ E X C E P T I O N _ C O M M O N ( 0 x98 0 , h d e c r e m e n t e r , . h d e c _ i n t e r r u p t )
2009-06-03 01:17:38 +04:00
STD_ E X C E P T I O N _ C O M M O N ( 0 x a00 , t r a p _ 0 a , . u n k n o w n _ e x c e p t i o n )
STD_ E X C E P T I O N _ C O M M O N ( 0 x b00 , t r a p _ 0 b , . u n k n o w n _ e x c e p t i o n )
STD_ E X C E P T I O N _ C O M M O N ( 0 x d00 , s i n g l e _ s t e p , . s i n g l e _ s t e p _ e x c e p t i o n )
STD_ E X C E P T I O N _ C O M M O N ( 0 x e 0 0 , t r a p _ 0 e , . u n k n o w n _ e x c e p t i o n )
2012-11-02 07:11:51 +04:00
STD_ E X C E P T I O N _ C O M M O N ( 0 x e 4 0 , e m u l a t i o n _ a s s i s t , . p r o g r a m _ c h e c k _ e x c e p t i o n )
STD_ E X C E P T I O N _ C O M M O N ( 0 x e 6 0 , h m i _ e x c e p t i o n , . u n k n o w n _ e x c e p t i o n )
2012-03-01 03:52:01 +04:00
STD_ E X C E P T I O N _ C O M M O N _ A S Y N C ( 0 x f00 , p e r f o r m a n c e _ m o n i t o r , . p e r f o r m a n c e _ m o n i t o r _ e x c e p t i o n )
2009-06-03 01:17:38 +04:00
STD_ E X C E P T I O N _ C O M M O N ( 0 x13 0 0 , i n s t r u c t i o n _ b r e a k p o i n t , . i n s t r u c t i o n _ b r e a k p o i n t _ e x c e p t i o n )
2012-09-10 04:35:26 +04:00
STD_ E X C E P T I O N _ C O M M O N ( 0 x15 0 2 , d e n o r m , . u n k n o w n _ e x c e p t i o n )
2009-06-03 01:17:38 +04:00
# ifdef C O N F I G _ A L T I V E C
STD_ E X C E P T I O N _ C O M M O N ( 0 x17 0 0 , a l t i v e c _ a s s i s t , . a l t i v e c _ a s s i s t _ e x c e p t i o n )
# else
STD_ E X C E P T I O N _ C O M M O N ( 0 x17 0 0 , a l t i v e c _ a s s i s t , . u n k n o w n _ e x c e p t i o n )
# endif
# ifdef C O N F I G _ C B E _ R A S
STD_ E X C E P T I O N _ C O M M O N ( 0 x12 0 0 , c b e _ s y s t e m _ e r r o r , . c b e _ s y s t e m _ e r r o r _ e x c e p t i o n )
STD_ E X C E P T I O N _ C O M M O N ( 0 x16 0 0 , c b e _ m a i n t e n a n c e , . c b e _ m a i n t e n a n c e _ e x c e p t i o n )
STD_ E X C E P T I O N _ C O M M O N ( 0 x18 0 0 , c b e _ t h e r m a l , . c b e _ t h e r m a l _ e x c e p t i o n )
# endif / * C O N F I G _ C B E _ R A S * /
2012-11-02 10:21:43 +04:00
/ *
* Relocation- o n i n t e r r u p t s : A s u b s e t o f t h e i n t e r r u p t s c a n b e d e l i v e r e d
* with I R =1 / D R =1 , i f A I L = =2 a n d M S R . H V w o n ' t b e c h a n g e d b y d e l i v e r i n g
* it. A d d r e s s e s a r e t h e s a m e a s t h e o r i g i n a l i n t e r r u p t a d d r e s s e s , b u t
* offset b y 0 x c00 0 0 0 0 0 0 0 0 0 4 0 0 0 .
* It' s i m p o s s i b l e t o r e c e i v e i n t e r r u p t s b e l o w 0 x30 0 v i a t h i s m e c h a n i s m .
* KVM : None o f t h e s e t r a p s a r e f r o m t h e g u e s t ; anything that escalated
* to H V =1 f r o m H V =0 i s d e l i v e r e d v i a r e a l m o d e h a n d l e r s .
* /
/ *
* This u s e s t h e s t a n d a r d m a c r o , s i n c e t h e o r i g i n a l 0 x30 0 v e c t o r
* only h a s e x t r a g u f f f o r S T A B - b a s e d p r o c e s s o r s - - w h i c h n e v e r
* come h e r e .
* /
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x43 0 0 , 0 x30 0 , d a t a _ a c c e s s )
. = 0 x4 3 8 0
.globl data_access_slb_relon_pSeries
data_access_slb_relon_pSeries :
HMT_ M E D I U M
SET_ S C R A T C H 0 ( r13 )
EXCEPTION_ P R O L O G _ 1 ( P A C A _ E X S L B , N O T E S T , 0 x38 0 )
std r3 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
mfspr r3 ,S P R N _ D A R
mfspr r12 ,S P R N _ S R R 1
# ifndef C O N F I G _ R E L O C A T A B L E
b . s l b _ m i s s _ r e a l m o d e
# else
/ *
* We c a n ' t j u s t u s e a d i r e c t b r a n c h t o . s l b _ m i s s _ r e a l m o d e
* because t h e d i s t a n c e f r o m h e r e t o t h e r e d e p e n d s o n w h e r e
* the k e r n e l e n d s u p b e i n g p u t .
* /
mfctr r11
ld r10 ,P A C A K B A S E ( r13 )
LOAD_ H A N D L E R ( r10 , . s l b _ m i s s _ r e a l m o d e )
mtctr r10
bctr
# endif
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x44 0 0 , 0 x40 0 , i n s t r u c t i o n _ a c c e s s )
. = 0 x4 4 8 0
.globl instruction_access_slb_relon_pSeries
instruction_access_slb_relon_pSeries :
HMT_ M E D I U M
SET_ S C R A T C H 0 ( r13 )
EXCEPTION_ P R O L O G _ 1 ( P A C A _ E X S L B , N O T E S T , 0 x48 0 )
std r3 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
mfspr r3 ,S P R N _ S R R 0 / * S R R 0 i s f a u l t i n g a d d r e s s * /
mfspr r12 ,S P R N _ S R R 1
# ifndef C O N F I G _ R E L O C A T A B L E
b . s l b _ m i s s _ r e a l m o d e
# else
mfctr r11
ld r10 ,P A C A K B A S E ( r13 )
LOAD_ H A N D L E R ( r10 , . s l b _ m i s s _ r e a l m o d e )
mtctr r10
bctr
# endif
. = 0 x4 5 0 0
.globl hardware_ i n t e r r u p t _ r e l o n _ p S e r i e s ;
.globl hardware_ i n t e r r u p t _ r e l o n _ h v ;
hardware_interrupt_relon_pSeries :
hardware_interrupt_relon_hv :
BEGIN_ F T R _ S E C T I O N
_ MASKABLE_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x50 2 , h a r d w a r e _ i n t e r r u p t , E X C _ H V , S O F T E N _ T E S T _ H V )
FTR_ S E C T I O N _ E L S E
_ MASKABLE_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x50 0 , h a r d w a r e _ i n t e r r u p t , E X C _ S T D , S O F T E N _ T E S T _ P R )
ALT_ F T R _ S E C T I O N _ E N D _ I F S E T ( C P U _ F T R _ A R C H _ 2 0 6 )
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x46 0 0 , 0 x60 0 , a l i g n m e n t )
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x47 0 0 , 0 x70 0 , p r o g r a m _ c h e c k )
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x48 0 0 , 0 x80 0 , f p _ u n a v a i l a b l e )
MASKABLE_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x49 0 0 , 0 x90 0 , d e c r e m e n t e r )
STD_ R E L O N _ E X C E P T I O N _ H V ( 0 x49 8 0 , 0 x98 2 , h d e c r e m e n t e r )
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x4 b00 , 0 x b00 , t r a p _ 0 b )
. = 0 x4 c00
.globl system_call_relon_pSeries
system_call_relon_pSeries :
HMT_ M E D I U M
SYSCALL_ P S E R I E S _ 1
SYSCALL_ P S E R I E S _ 2 _ D I R E C T
SYSCALL_ P S E R I E S _ 3
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x4 d00 , 0 x d00 , s i n g l e _ s t e p )
. = 0 x4 e 0 0
b h _ d a t a _ s t o r a g e _ r e l o n _ h v
. = 0 x4 e 2 0
b h _ i n s t r _ s t o r a g e _ r e l o n _ h v
. = 0 x4 e 4 0
b e m u l a t i o n _ a s s i s t _ r e l o n _ h v
. = 0 x4 e 5 0
b h m i _ e x c e p t i o n _ r e l o n _ h v
. = 0 x4 e 6 0
b h m i _ e x c e p t i o n _ r e l o n _ h v
/ * For w h e n w e s u p p o r t t h e d o o r b e l l i n t e r r u p t :
STD_ R E L O N _ E X C E P T I O N _ H Y P E R V I S O R ( 0 x4 e 8 0 , 0 x e 8 0 , d o o r b e l l _ h y p e r )
* /
performance_monitor_relon_pSeries_1 :
. = 0 x4 f00
b p e r f o r m a n c e _ m o n i t o r _ r e l o n _ p S e r i e s
altivec_unavailable_relon_pSeries_1 :
. = 0 x4 f20
b a l t i v e c _ u n a v a i l a b l e _ r e l o n _ p S e r i e s
vsx_unavailable_relon_pSeries_1 :
. = 0 x4 f40
b v s x _ u n a v a i l a b l e _ r e l o n _ p S e r i e s
# ifdef C O N F I G _ C B E _ R A S
STD_ R E L O N _ E X C E P T I O N _ H V ( 0 x52 0 0 , 0 x12 0 2 , c b e _ s y s t e m _ e r r o r )
# endif / * C O N F I G _ C B E _ R A S * /
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x53 0 0 , 0 x13 0 0 , i n s t r u c t i o n _ b r e a k p o i n t )
# ifdef C O N F I G _ P P C _ D E N O R M A L I S A T I O N
. = 0 x5 5 0 0
b d e n o r m _ e x c e p t i o n _ h v
# endif
# ifdef C O N F I G _ C B E _ R A S
STD_ R E L O N _ E X C E P T I O N _ H V ( 0 x56 0 0 , 0 x16 0 2 , c b e _ m a i n t e n a n c e )
# else
# ifdef C O N F I G _ H V C _ S C O M
STD_ R E L O N _ E X C E P T I O N _ H V ( 0 x56 0 0 , 0 x16 0 0 , m a i n t e n c e _ i n t e r r u p t )
KVM_ H A N D L E R _ S K I P ( P A C A _ E X G E N , E X C _ H V , 0 x16 0 0 )
# endif / * C O N F I G _ H V C _ S C O M * /
# endif / * C O N F I G _ C B E _ R A S * /
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( 0 x57 0 0 , 0 x17 0 0 , a l t i v e c _ a s s i s t )
# ifdef C O N F I G _ C B E _ R A S
STD_ R E L O N _ E X C E P T I O N _ H V ( 0 x58 0 0 , 0 x18 0 2 , c b e _ t h e r m a l )
# endif / * C O N F I G _ C B E _ R A S * /
/* Other future vectors */
.align 7
.globl __end_interrupts
__end_interrupts :
2009-06-03 01:17:38 +04:00
.align 7
2012-11-02 10:21:43 +04:00
system_call_entry_direct :
# if d e f i n e d ( C O N F I G _ R E L O C A T A B L E )
/ * The f i r s t l e v e l p r o l o g u e m a y h a v e u s e d L R t o g e t h e r e , s a v i n g
* orig i n r10 . T o s a v e h a c k i n g / i f d e f f i n g c o m m o n c o d e , r e s t o r e h e r e .
* /
mtlr r10
# endif
2009-06-03 01:17:38 +04:00
system_call_entry :
b s y s t e m _ c a l l _ c o m m o n
2012-03-01 05:45:27 +04:00
ppc64_runlatch_on_trampoline :
b . _ _ p p c64 _ r u n l a t c h _ o n
2009-06-03 01:17:38 +04:00
/ *
* Here w e h a v e d e t e c t e d t h a t t h e k e r n e l s t a c k p o i n t e r i s b a d .
* R9 c o n t a i n s t h e s a v e d C R , r13 p o i n t s t o t h e p a c a ,
* r1 0 c o n t a i n s t h e ( b a d ) k e r n e l s t a c k p o i n t e r ,
* r1 1 a n d r12 c o n t a i n t h e s a v e d S R R 0 a n d S R R 1 .
* We s w i t c h t o u s i n g a n e m e r g e n c y s t a c k , s a v e t h e r e g i s t e r s t h e r e ,
* and c a l l k e r n e l _ b a d _ s t a c k ( ) , w h i c h p a n i c s .
* /
bad_stack :
ld r1 ,P A C A E M E R G S P ( r13 )
subi r1 ,r1 ,6 4 + I N T _ F R A M E _ S I Z E
std r9 ,_ C C R ( r1 )
std r10 ,G P R 1 ( r1 )
std r11 ,_ N I P ( r1 )
std r12 ,_ M S R ( r1 )
mfspr r11 ,S P R N _ D A R
mfspr r12 ,S P R N _ D S I S R
std r11 ,_ D A R ( r1 )
std r12 ,_ D S I S R ( r1 )
mflr r10
mfctr r11
mfxer r12
std r10 ,_ L I N K ( r1 )
std r11 ,_ C T R ( r1 )
std r12 ,_ X E R ( r1 )
SAVE_ G P R ( 0 ,r1 )
SAVE_ G P R ( 2 ,r1 )
2011-05-01 23:46:44 +04:00
ld r10 ,E X _ R 3 ( r3 )
std r10 ,G P R 3 ( r1 )
SAVE_ G P R ( 4 ,r1 )
SAVE_ 4 G P R S ( 5 ,r1 )
ld r9 ,E X _ R 9 ( r3 )
ld r10 ,E X _ R 1 0 ( r3 )
SAVE_ 2 G P R S ( 9 ,r1 )
ld r9 ,E X _ R 1 1 ( r3 )
ld r10 ,E X _ R 1 2 ( r3 )
ld r11 ,E X _ R 1 3 ( r3 )
std r9 ,G P R 1 1 ( r1 )
std r10 ,G P R 1 2 ( r1 )
std r11 ,G P R 1 3 ( r1 )
2011-05-01 23:48:20 +04:00
BEGIN_ F T R _ S E C T I O N
ld r10 ,E X _ C F A R ( r3 )
std r10 ,O R I G _ G P R 3 ( r1 )
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ C F A R )
2011-05-01 23:46:44 +04:00
SAVE_ 8 G P R S ( 1 4 ,r1 )
2009-06-03 01:17:38 +04:00
SAVE_ 1 0 G P R S ( 2 2 ,r1 )
lhz r12 ,P A C A _ T R A P _ S A V E ( r13 )
std r12 ,_ T R A P ( r1 )
addi r11 ,r1 ,I N T _ F R A M E _ S I Z E
std r11 ,0 ( r1 )
li r12 ,0
std r12 ,0 ( r11 )
ld r2 ,P A C A T O C ( r13 )
2011-05-01 23:46:44 +04:00
ld r11 ,e x c e p t i o n _ m a r k e r @toc(r2)
std r12 ,R E S U L T ( r1 )
std r11 ,S T A C K _ F R A M E _ O V E R H E A D - 1 6 ( r1 )
2009-06-03 01:17:38 +04:00
1 : addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . k e r n e l _ b a d _ s t a c k
b 1 b
/ *
* Here r13 p o i n t s t o t h e p a c a , r9 c o n t a i n s t h e s a v e d C R ,
* SRR0 a n d S R R 1 a r e s a v e d i n r11 a n d r12 ,
* r9 - r13 a r e s a v e d i n p a c a - > e x g e n .
* /
.align 7
.globl data_access_common
data_access_common :
mfspr r10 ,S P R N _ D A R
std r10 ,P A C A _ E X G E N + E X _ D A R ( r13 )
mfspr r10 ,S P R N _ D S I S R
stw r10 ,P A C A _ E X G E N + E X _ D S I S R ( r13 )
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x30 0 , P A C A _ E X G E N )
2012-03-07 09:48:45 +04:00
DISABLE_ I N T S
ld r12 ,_ M S R ( r1 )
2009-06-03 01:17:38 +04:00
ld r3 ,P A C A _ E X G E N + E X _ D A R ( r13 )
lwz r4 ,P A C A _ E X G E N + E X _ D S I S R ( r13 )
li r5 ,0 x30 0
2012-11-02 07:11:51 +04:00
b . d o _ h a s h _ p a g e / * T r y t o h a n d l e a s h p t e f a u l t * /
2009-06-03 01:17:38 +04:00
2011-04-05 08:27:11 +04:00
.align 7
2012-11-02 07:11:51 +04:00
.globl h_data_storage_common
2011-04-05 08:27:11 +04:00
h_data_storage_common :
2012-11-02 07:11:51 +04:00
mfspr r10 ,S P R N _ H D A R
std r10 ,P A C A _ E X G E N + E X _ D A R ( r13 )
mfspr r10 ,S P R N _ H D S I S R
stw r10 ,P A C A _ E X G E N + E X _ D S I S R ( r13 )
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x e 0 0 , P A C A _ E X G E N )
bl . s a v e _ n v g p r s
2012-03-07 09:48:45 +04:00
DISABLE_ I N T S
2012-11-02 07:11:51 +04:00
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . u n k n o w n _ e x c e p t i o n
b . r e t _ f r o m _ e x c e p t
2011-04-05 08:27:11 +04:00
2009-06-03 01:17:38 +04:00
.align 7
.globl instruction_access_common
instruction_access_common :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x40 0 , P A C A _ E X G E N )
2012-03-07 09:48:45 +04:00
DISABLE_ I N T S
ld r12 ,_ M S R ( r1 )
2009-06-03 01:17:38 +04:00
ld r3 ,_ N I P ( r1 )
andis. r4 ,r12 ,0 x58 2 0
li r5 ,0 x40 0
b . d o _ h a s h _ p a g e / * T r y t o h a n d l e a s h p t e f a u l t * /
2012-11-02 07:11:51 +04:00
STD_ E X C E P T I O N _ C O M M O N ( 0 x e 2 0 , h _ i n s t r _ s t o r a g e , . u n k n o w n _ e x c e p t i o n )
2011-04-05 08:27:11 +04:00
2009-06-03 01:17:38 +04:00
/ *
* Here i s t h e c o m m o n S L B m i s s u s e r t h a t i s u s e d w h e n g o i n g t o v i r t u a l
* mode f o r S L B m i s s e s , t h a t i s c u r r e n t l y n o t u s e d
* /
# ifdef _ _ D I S A B L E D _ _
.align 7
.globl slb_miss_user_common
slb_miss_user_common :
mflr r10
std r3 ,P A C A _ E X G E N + E X _ D A R ( r13 )
stw r9 ,P A C A _ E X G E N + E X _ C C R ( r13 )
std r10 ,P A C A _ E X G E N + E X _ L R ( r13 )
std r11 ,P A C A _ E X G E N + E X _ S R R 0 ( r13 )
bl . s l b _ a l l o c a t e _ u s e r
ld r10 ,P A C A _ E X G E N + E X _ L R ( r13 )
ld r3 ,P A C A _ E X G E N + E X _ R 3 ( r13 )
lwz r9 ,P A C A _ E X G E N + E X _ C C R ( r13 )
ld r11 ,P A C A _ E X G E N + E X _ S R R 0 ( r13 )
mtlr r10
beq- s l b _ m i s s _ f a u l t
andi. r10 ,r12 ,M S R _ R I / * c h e c k f o r u n r e c o v e r a b l e e x c e p t i o n * /
beq- u n r e c o v _ u s e r _ s l b
mfmsr r10
.machine push
.machine " power4 "
mtcrf 0 x80 ,r9
.machine pop
clrrdi r10 ,r10 ,2 / * c l e a r R I b e f o r e s e t t i n g S R R 0 / 1 * /
mtmsrd r10 ,1
mtspr S R R 0 ,r11
mtspr S R R 1 ,r12
ld r9 ,P A C A _ E X G E N + E X _ R 9 ( r13 )
ld r10 ,P A C A _ E X G E N + E X _ R 1 0 ( r13 )
ld r11 ,P A C A _ E X G E N + E X _ R 1 1 ( r13 )
ld r12 ,P A C A _ E X G E N + E X _ R 1 2 ( r13 )
ld r13 ,P A C A _ E X G E N + E X _ R 1 3 ( r13 )
rfid
b .
slb_miss_fault :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x38 0 , P A C A _ E X G E N )
ld r4 ,P A C A _ E X G E N + E X _ D A R ( r13 )
li r5 ,0
std r4 ,_ D A R ( r1 )
std r5 ,_ D S I S R ( r1 )
b h a n d l e _ p a g e _ f a u l t
unrecov_user_slb :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x42 0 0 , P A C A _ E X G E N )
DISABLE_ I N T S
bl . s a v e _ n v g p r s
1 : addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . u n r e c o v e r a b l e _ e x c e p t i o n
b 1 b
# endif / * _ _ D I S A B L E D _ _ * /
/ *
* r1 3 p o i n t s t o t h e P A C A , r9 c o n t a i n s t h e s a v e d C R ,
* r1 2 c o n t a i n t h e s a v e d S R R 1 , S R R 0 i s s t i l l r e a d y f o r r e t u r n
* r3 h a s t h e f a u l t i n g a d d r e s s
* r9 - r13 a r e s a v e d i n p a c a - > e x s l b .
* r3 i s s a v e d i n p a c a - > s l b _ r3
* We a s s u m e w e a r e n ' t g o i n g t o t a k e a n y e x c e p t i o n s d u r i n g t h i s p r o c e d u r e .
* /
_ GLOBAL( s l b _ m i s s _ r e a l m o d e )
mflr r10
# ifdef C O N F I G _ R E L O C A T A B L E
mtctr r11
# endif
stw r9 ,P A C A _ E X S L B + E X _ C C R ( r13 ) / * s a v e C R i n e x c . f r a m e * /
std r10 ,P A C A _ E X S L B + E X _ L R ( r13 ) / * s a v e L R * /
bl . s l b _ a l l o c a t e _ r e a l m o d e
/* All done -- return from exception. */
ld r10 ,P A C A _ E X S L B + E X _ L R ( r13 )
ld r3 ,P A C A _ E X S L B + E X _ R 3 ( r13 )
lwz r9 ,P A C A _ E X S L B + E X _ C C R ( r13 ) / * g e t s a v e d C R * /
mtlr r10
andi. r10 ,r12 ,M S R _ R I / * c h e c k f o r u n r e c o v e r a b l e e x c e p t i o n * /
beq- 2 f
.machine push
.machine " power4 "
mtcrf 0 x80 ,r9
mtcrf 0 x01 ,r9 / * s l b _ a l l o c a t e u s e s c r0 a n d c r7 * /
.machine pop
ld r9 ,P A C A _ E X S L B + E X _ R 9 ( r13 )
ld r10 ,P A C A _ E X S L B + E X _ R 1 0 ( r13 )
ld r11 ,P A C A _ E X S L B + E X _ R 1 1 ( r13 )
ld r12 ,P A C A _ E X S L B + E X _ R 1 2 ( r13 )
ld r13 ,P A C A _ E X S L B + E X _ R 1 3 ( r13 )
rfid
b . / * p r e v e n t s p e c u l a t i v e e x e c u t i o n * /
2012-02-28 06:44:58 +04:00
2 : mfspr r11 ,S P R N _ S R R 0
2009-06-03 01:17:38 +04:00
ld r10 ,P A C A K B A S E ( r13 )
LOAD_ H A N D L E R ( r10 ,u n r e c o v _ s l b )
mtspr S P R N _ S R R 0 ,r10
ld r10 ,P A C A K M S R ( r13 )
mtspr S P R N _ S R R 1 ,r10
rfid
b .
unrecov_slb :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x41 0 0 , P A C A _ E X S L B )
DISABLE_ I N T S
bl . s a v e _ n v g p r s
1 : addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . u n r e c o v e r a b l e _ e x c e p t i o n
b 1 b
# ifdef C O N F I G _ P P C _ 9 7 0 _ N A P
power4_fixup_nap :
andc r9 ,r9 ,r10
std r9 ,T I _ L O C A L _ F L A G S ( r11 )
ld r10 ,_ L I N K ( r1 ) / * m a k e i d l e t a s k d o t h e * /
std r10 ,_ N I P ( r1 ) / * e q u i v a l e n t o f a b l r * /
blr
# endif
.align 7
.globl alignment_common
alignment_common :
mfspr r10 ,S P R N _ D A R
std r10 ,P A C A _ E X G E N + E X _ D A R ( r13 )
mfspr r10 ,S P R N _ D S I S R
stw r10 ,P A C A _ E X G E N + E X _ D S I S R ( r13 )
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x60 0 , P A C A _ E X G E N )
ld r3 ,P A C A _ E X G E N + E X _ D A R ( r13 )
lwz r4 ,P A C A _ E X G E N + E X _ D S I S R ( r13 )
std r3 ,_ D A R ( r1 )
std r4 ,_ D S I S R ( r1 )
bl . s a v e _ n v g p r s
2012-05-08 07:38:50 +04:00
DISABLE_ I N T S
2009-06-03 01:17:38 +04:00
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . a l i g n m e n t _ e x c e p t i o n
b . r e t _ f r o m _ e x c e p t
.align 7
.globl program_check_common
program_check_common :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x70 0 , P A C A _ E X G E N )
bl . s a v e _ n v g p r s
2012-02-14 00:42:18 +04:00
DISABLE_ I N T S
2012-02-21 01:32:30 +04:00
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
2009-06-03 01:17:38 +04:00
bl . p r o g r a m _ c h e c k _ e x c e p t i o n
b . r e t _ f r o m _ e x c e p t
.align 7
.globl fp_unavailable_common
fp_unavailable_common :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x80 0 , P A C A _ E X G E N )
bne 1 f / * i f f r o m u s e r , j u s t l o a d i t u p * /
bl . s a v e _ n v g p r s
2012-03-01 08:47:44 +04:00
DISABLE_ I N T S
2009-06-03 01:17:38 +04:00
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . k e r n e l _ f p _ u n a v a i l a b l e _ e x c e p t i o n
BUG_ O P C O D E
1 : bl . l o a d _ u p _ f p u
b f a s t _ e x c e p t i o n _ r e t u r n
.align 7
.globl altivec_unavailable_common
altivec_unavailable_common :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x f20 , P A C A _ E X G E N )
# ifdef C O N F I G _ A L T I V E C
BEGIN_ F T R _ S E C T I O N
beq 1 f
bl . l o a d _ u p _ a l t i v e c
b f a s t _ e x c e p t i o n _ r e t u r n
1 :
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ A L T I V E C )
# endif
bl . s a v e _ n v g p r s
2012-03-01 08:47:44 +04:00
DISABLE_ I N T S
2009-06-03 01:17:38 +04:00
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . a l t i v e c _ u n a v a i l a b l e _ e x c e p t i o n
b . r e t _ f r o m _ e x c e p t
.align 7
.globl vsx_unavailable_common
vsx_unavailable_common :
EXCEPTION_ P R O L O G _ C O M M O N ( 0 x f40 , P A C A _ E X G E N )
# ifdef C O N F I G _ V S X
BEGIN_ F T R _ S E C T I O N
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
beq 1 f
b . l o a d _ u p _ v s x
2009-06-03 01:17:38 +04:00
1 :
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ V S X )
# endif
bl . s a v e _ n v g p r s
2012-03-01 08:47:44 +04:00
DISABLE_ I N T S
2009-06-03 01:17:38 +04:00
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . v s x _ u n a v a i l a b l e _ e x c e p t i o n
b . r e t _ f r o m _ e x c e p t
.align 7
.globl __end_handlers
__end_handlers :
/ *
* Hash t a b l e s t u f f
* /
.align 7
_ STATIC( d o _ h a s h _ p a g e )
std r3 ,_ D A R ( r1 )
std r4 ,_ D S I S R ( r1 )
2010-03-30 03:59:25 +04:00
andis. r0 ,r4 ,0 x a41 0 / * w e i r d e r r o r ? * /
2009-06-03 01:17:38 +04:00
bne- h a n d l e _ p a g e _ f a u l t / * i f n o t , t r y t o i n s e r t a H P T E * /
2010-03-30 03:59:25 +04:00
andis. r0 ,r4 ,D S I S R _ D A B R M A T C H @h
bne- h a n d l e _ d a b r _ f a u l t
2009-06-03 01:17:38 +04:00
BEGIN_ F T R _ S E C T I O N
andis. r0 ,r4 ,0 x00 2 0 / * I s i t a s e g m e n t t a b l e f a u l t ? * /
bne- d o _ s t e _ a l l o c / * I f s o h a n d l e i t * /
2011-04-06 23:48:50 +04:00
END_ M M U _ F T R _ S E C T I O N _ I F C L R ( M M U _ F T R _ S L B )
2009-06-03 01:17:38 +04:00
2012-07-05 08:41:35 +04:00
CURRENT_ T H R E A D _ I N F O ( r11 , r1 )
powerpc: Allow perf_counters to access user memory at interrupt time
This provides a mechanism to allow the perf_counters code to access
user memory in a PMU interrupt routine. Such an access can cause
various kinds of interrupt: SLB miss, MMU hash table miss, segment
table miss, or TLB miss, depending on the processor. This commit
only deals with 64-bit classic/server processors, which use an MMU
hash table. 32-bit processors are already able to access user memory
at interrupt time. Since we don't soft-disable on 32-bit, we avoid
the possibility of reentering hash_page or the TLB miss handlers,
since they run with interrupts disabled.
On 64-bit processors, an SLB miss interrupt on a user address will
update the slb_cache and slb_cache_ptr fields in the paca. This is
OK except in the case where a PMU interrupt occurs in switch_slb,
which also accesses those fields. To prevent this, we hard-disable
interrupts in switch_slb. Interrupts are already soft-disabled at
this point, and will get hard-enabled when they get soft-enabled
later.
This also reworks slb_flush_and_rebolt: to avoid hard-disabling twice,
and to make sure that it clears the slb_cache_ptr when called from
other callers than switch_slb, the existing routine is renamed to
__slb_flush_and_rebolt, which is called by switch_slb and the new
version of slb_flush_and_rebolt.
Similarly, switch_stab (used on POWER3 and RS64 processors) gets a
hard_irq_disable() to protect the per-cpu variables used there and
in ste_allocate.
If a MMU hashtable miss interrupt occurs, normally we would call
hash_page to look up the Linux PTE for the address and create a HPTE.
However, hash_page is fairly complex and takes some locks, so to
avoid the possibility of deadlock, we check the preemption count
to see if we are in a (pseudo-)NMI handler, and if so, we don't call
hash_page but instead treat it like a bad access that will get
reported up through the exception table mechanism. An interrupt
whose handler runs even though the interrupt occurred when
soft-disabled (such as the PMU interrupt) is considered a pseudo-NMI
handler, which should use nmi_enter()/nmi_exit() rather than
irq_enter()/irq_exit().
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2009-08-17 09:17:54 +04:00
lwz r0 ,T I _ P R E E M P T ( r11 ) / * I f w e ' r e i n a n " N M I " * /
andis. r0 ,r0 ,N M I _ M A S K @h /* (i.e. an irq when soft-disabled) */
bne 7 7 f / * t h e n d o n ' t c a l l h a s h _ p a g e n o w * /
2009-06-03 01:17:38 +04:00
/ *
* We n e e d t o s e t t h e _ P A G E _ U S E R b i t i f M S R _ P R i s s e t o r i f w e a r e
* accessing a u s e r s p a c e s e g m e n t ( e v e n f r o m t h e k e r n e l ) . W e a s s u m e
* kernel a d d r e s s e s a l w a y s h a v e t h e h i g h b i t s e t .
* /
rlwinm r4 ,r4 ,3 2 - 2 5 + 9 ,3 1 - 9 ,3 1 - 9 / * D S I S R _ S T O R E - > _ P A G E _ R W * /
rotldi r0 ,r3 ,1 5 / * M o v e h i g h b i t i n t o M S R _ P R p o s n * /
orc r0 ,r12 ,r0 / * M S R _ P R | ~ h i g h _ b i t * /
rlwimi r4 ,r0 ,3 2 - 1 3 ,3 0 ,3 0 / * b e c o m e s _ P A G E _ U S E R a c c e s s b i t * /
ori r4 ,r4 ,1 / * a d d _ P A G E _ P R E S E N T * /
rlwimi r4 ,r5 ,2 2 + 2 ,3 1 - 2 ,3 1 - 2 / * S e t _ P A G E _ E X E C i f t r a p i s 0 x40 0 * /
/ *
* r3 c o n t a i n s t h e f a u l t i n g a d d r e s s
* r4 c o n t a i n s t h e r e q u i r e d a c c e s s p e r m i s s i o n s
* r5 c o n t a i n s t h e t r a p n u m b e r
*
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
* at r e t u r n r3 = 0 f o r s u c c e s s , 1 f o r p a g e f a u l t , n e g a t i v e f o r e r r o r
2009-06-03 01:17:38 +04:00
* /
bl . h a s h _ p a g e / * b u i l d H P T E i f p o s s i b l e * /
cmpdi r3 ,0 / * s e e i f h a s h _ p a g e s u c c e e d e d * /
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
/* Success */
2009-06-03 01:17:38 +04:00
beq f a s t _ e x c _ r e t u r n _ i r q / * R e t u r n f r o m e x c e p t i o n o n s u c c e s s * /
powerpc: Rework lazy-interrupt handling
The current implementation of lazy interrupts handling has some
issues that this tries to address.
We don't do the various workarounds we need to do when re-enabling
interrupts in some cases such as when returning from an interrupt
and thus we may still lose or get delayed decrementer or doorbell
interrupts.
The current scheme also makes it much harder to handle the external
"edge" interrupts provided by some BookE processors when using the
EPR facility (External Proxy) and the Freescale Hypervisor.
Additionally, we tend to keep interrupts hard disabled in a number
of cases, such as decrementer interrupts, external interrupts, or
when a masked decrementer interrupt is pending. This is sub-optimal.
This is an attempt at fixing it all in one go by reworking the way
we do the lazy interrupt disabling from the ground up.
The base idea is to replace the "hard_enabled" field with a
"irq_happened" field in which we store a bit mask of what interrupt
occurred while soft-disabled.
When re-enabling, either via arch_local_irq_restore() or when returning
from an interrupt, we can now decide what to do by testing bits in that
field.
We then implement replaying of the missed interrupts either by
re-using the existing exception frame (in exception exit case) or via
the creation of a new one from an assembly trampoline (in the
arch_local_irq_enable case).
This removes the need to play with the decrementer to try to create
fake interrupts, among others.
In addition, this adds a few refinements:
- We no longer hard disable decrementer interrupts that occur
while soft-disabled. We now simply bump the decrementer back to max
(on BookS) or leave it stopped (on BookE) and continue with hard interrupts
enabled, which means that we'll potentially get better sample quality from
performance monitor interrupts.
- Timer, decrementer and doorbell interrupts now hard-enable
shortly after removing the source of the interrupt, which means
they no longer run entirely hard disabled. Again, this will improve
perf sample quality.
- On Book3E 64-bit, we now make the performance monitor interrupt
act as an NMI like Book3S (the necessary C code for that to work
appear to already be present in the FSL perf code, notably calling
nmi_enter instead of irq_enter). (This also fixes a bug where BookE
perfmon interrupts could clobber r14 ... oops)
- We could make "masked" decrementer interrupts act as NMIs when doing
timer-based perf sampling to improve the sample quality.
Signed-off-by-yet: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
v2:
- Add hard-enable to decrementer, timer and doorbells
- Fix CR clobber in masked irq handling on BookE
- Make embedded perf interrupt act as an NMI
- Add a PACA_HAPPENED_EE_EDGE for use by FSL if they want
to retrigger an interrupt without preventing hard-enable
v3:
- Fix or vs. ori bug on Book3E
- Fix enabling of interrupts for some exceptions on Book3E
v4:
- Fix resend of doorbells on return from interrupt on Book3E
v5:
- Rebased on top of my latest series, which involves some significant
rework of some aspects of the patch.
v6:
- 32-bit compile fix
- more compile fixes with various .config combos
- factor out the asm code to soft-disable interrupts
- remove the C wrapper around preempt_schedule_irq
v7:
- Fix a bug with hard irq state tracking on native power7
2012-03-06 11:27:59 +04:00
/* Error */
blt- 1 3 f
2010-03-30 03:59:25 +04:00
2009-06-03 01:17:38 +04:00
/* Here we have a page fault that hash_page can't handle. */
handle_page_fault :
11 : ld r4 ,_ D A R ( r1 )
ld r5 ,_ D S I S R ( r1 )
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . d o _ p a g e _ f a u l t
cmpdi r3 ,0
2012-03-07 09:48:45 +04:00
beq+ 1 2 f
2009-06-03 01:17:38 +04:00
bl . s a v e _ n v g p r s
mr r5 ,r3
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
lwz r4 ,_ D A R ( r1 )
bl . b a d _ p a g e _ f a u l t
b . r e t _ f r o m _ e x c e p t
2012-03-07 09:48:45 +04:00
/* We have a data breakpoint exception - handle it */
handle_dabr_fault :
bl . s a v e _ n v g p r s
ld r4 ,_ D A R ( r1 )
ld r5 ,_ D S I S R ( r1 )
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
bl . d o _ d a b r
12 : b . r e t _ f r o m _ e x c e p t _ l i t e
2009-06-03 01:17:38 +04:00
/ * We h a v e a p a g e f a u l t t h a t h a s h _ p a g e c o u l d h a n d l e b u t H V r e f u s e d
* the P T E i n s e r t i o n
* /
2012-03-07 09:48:45 +04:00
13 : bl . s a v e _ n v g p r s
2009-06-03 01:17:38 +04:00
mr r5 ,r3
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
ld r4 ,_ D A R ( r1 )
bl . l o w _ h a s h _ f a u l t
b . r e t _ f r o m _ e x c e p t
powerpc: Allow perf_counters to access user memory at interrupt time
This provides a mechanism to allow the perf_counters code to access
user memory in a PMU interrupt routine. Such an access can cause
various kinds of interrupt: SLB miss, MMU hash table miss, segment
table miss, or TLB miss, depending on the processor. This commit
only deals with 64-bit classic/server processors, which use an MMU
hash table. 32-bit processors are already able to access user memory
at interrupt time. Since we don't soft-disable on 32-bit, we avoid
the possibility of reentering hash_page or the TLB miss handlers,
since they run with interrupts disabled.
On 64-bit processors, an SLB miss interrupt on a user address will
update the slb_cache and slb_cache_ptr fields in the paca. This is
OK except in the case where a PMU interrupt occurs in switch_slb,
which also accesses those fields. To prevent this, we hard-disable
interrupts in switch_slb. Interrupts are already soft-disabled at
this point, and will get hard-enabled when they get soft-enabled
later.
This also reworks slb_flush_and_rebolt: to avoid hard-disabling twice,
and to make sure that it clears the slb_cache_ptr when called from
other callers than switch_slb, the existing routine is renamed to
__slb_flush_and_rebolt, which is called by switch_slb and the new
version of slb_flush_and_rebolt.
Similarly, switch_stab (used on POWER3 and RS64 processors) gets a
hard_irq_disable() to protect the per-cpu variables used there and
in ste_allocate.
If a MMU hashtable miss interrupt occurs, normally we would call
hash_page to look up the Linux PTE for the address and create a HPTE.
However, hash_page is fairly complex and takes some locks, so to
avoid the possibility of deadlock, we check the preemption count
to see if we are in a (pseudo-)NMI handler, and if so, we don't call
hash_page but instead treat it like a bad access that will get
reported up through the exception table mechanism. An interrupt
whose handler runs even though the interrupt occurred when
soft-disabled (such as the PMU interrupt) is considered a pseudo-NMI
handler, which should use nmi_enter()/nmi_exit() rather than
irq_enter()/irq_exit().
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2009-08-17 09:17:54 +04:00
/ *
* We c o m e h e r e a s a r e s u l t o f a D S I a t a p o i n t w h e r e w e d o n ' t w a n t
* to c a l l h a s h _ p a g e , s u c h a s w h e n w e a r e a c c e s s i n g m e m o r y ( p o s s i b l y
* user m e m o r y ) i n s i d e a P M U i n t e r r u p t t h a t o c c u r r e d w h i l e i n t e r r u p t s
* were s o f t - d i s a b l e d . W e w a n t t o i n v o k e t h e e x c e p t i o n h a n d l e r f o r
* the a c c e s s , o r p a n i c i f t h e r e i s n ' t a h a n d l e r .
* /
77 : bl . s a v e _ n v g p r s
mr r4 ,r3
addi r3 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D
li r5 ,S I G S E G V
bl . b a d _ p a g e _ f a u l t
b . r e t _ f r o m _ e x c e p t
2009-06-03 01:17:38 +04:00
/* here we have a segment miss */
do_ste_alloc :
bl . s t e _ a l l o c a t e / * t r y t o i n s e r t s t a b e n t r y * /
cmpdi r3 ,0
bne- h a n d l e _ p a g e _ f a u l t
b f a s t _ e x c e p t i o n _ r e t u r n
/ *
* r1 3 p o i n t s t o t h e P A C A , r9 c o n t a i n s t h e s a v e d C R ,
* r1 1 a n d r12 c o n t a i n t h e s a v e d S R R 0 a n d S R R 1 .
* r9 - r13 a r e s a v e d i n p a c a - > e x s l b .
* We a s s u m e w e a r e n ' t g o i n g t o t a k e a n y e x c e p t i o n s d u r i n g t h i s p r o c e d u r e .
* We a s s u m e ( D A R > > 6 0 ) = = 0 x c .
* /
.align 7
_ GLOBAL( d o _ s t a b _ b o l t e d )
stw r9 ,P A C A _ E X S L B + E X _ C C R ( r13 ) / * s a v e C R i n e x c . f r a m e * /
std r11 ,P A C A _ E X S L B + E X _ S R R 0 ( r13 ) / * s a v e S R R 0 i n e x c . f r a m e * /
/* Hash to the primary group */
ld r10 ,P A C A S T A B V I R T ( r13 )
mfspr r11 ,S P R N _ D A R
srdi r11 ,r11 ,2 8
rldimi r10 ,r11 ,7 ,5 2 / * r10 = f i r s t s t e o f t h e g r o u p * /
/* Calculate VSID */
2012-09-10 06:52:55 +04:00
/* This is a kernel address, so protovsid = ESID | 1 << 37 */
li r9 ,0 x1
rldimi r11 ,r9 ,( C O N T E X T _ B I T S + U S E R _ E S I D _ B I T S ) ,0
2009-06-03 01:17:38 +04:00
ASM_ V S I D _ S C R A M B L E ( r11 , r9 , 2 5 6 M )
rldic r9 ,r11 ,1 2 ,1 6 / * r9 = v s i d < < 1 2 * /
/* Search the primary group for a free entry */
1 : ld r11 ,0 ( r10 ) / * T e s t v a l i d b i t o f t h e c u r r e n t s t e * /
andi. r11 ,r11 ,0 x80
beq 2 f
addi r10 ,r10 ,1 6
andi. r11 ,r10 ,0 x70
bne 1 b
/* Stick for only searching the primary group for now. */
/* At least for now, we use a very simple random castout scheme */
/* Use the TB as a random number ; OR in 1 to avoid entry 0 */
mftb r11
rldic r11 ,r11 ,4 ,5 7 / * r11 = ( r11 < < 4 ) & 0 x70 * /
ori r11 ,r11 ,0 x10
/* r10 currently points to an ste one past the group of interest */
/* make it point to the randomly selected entry */
subi r10 ,r10 ,1 2 8
or r10 ,r10 ,r11 / * r10 i s t h e e n t r y t o i n v a l i d a t e * /
isync / * m a r k t h e e n t r y i n v a l i d * /
ld r11 ,0 ( r10 )
rldicl r11 ,r11 ,5 6 ,1 / * c l e a r t h e v a l i d b i t * /
rotldi r11 ,r11 ,8
std r11 ,0 ( r10 )
sync
clrrdi r11 ,r11 ,2 8 / * G e t t h e e s i d p a r t o f t h e s t e * /
slbie r11
2 : std r9 ,8 ( r10 ) / * S t o r e t h e v s i d p a r t o f t h e s t e * /
eieio
mfspr r11 ,S P R N _ D A R / * G e t t h e n e w e s i d * /
clrrdi r11 ,r11 ,2 8 / * P e r m i t s a f u l l 3 2 b o f E S I D * /
ori r11 ,r11 ,0 x90 / * T u r n o n v a l i d a n d k p * /
std r11 ,0 ( r10 ) / * P u t n e w e n t r y b a c k i n t o t h e s t a b * /
sync
/* All done -- return from exception. */
lwz r9 ,P A C A _ E X S L B + E X _ C C R ( r13 ) / * g e t s a v e d C R * /
ld r11 ,P A C A _ E X S L B + E X _ S R R 0 ( r13 ) / * g e t s a v e d S R R 0 * /
andi. r10 ,r12 ,M S R _ R I
beq- u n r e c o v _ s l b
mtcrf 0 x80 ,r9 / * r e s t o r e C R * /
mfmsr r10
clrrdi r10 ,r10 ,2
mtmsrd r10 ,1
mtspr S P R N _ S R R 0 ,r11
mtspr S P R N _ S R R 1 ,r12
ld r9 ,P A C A _ E X S L B + E X _ R 9 ( r13 )
ld r10 ,P A C A _ E X S L B + E X _ R 1 0 ( r13 )
ld r11 ,P A C A _ E X S L B + E X _ R 1 1 ( r13 )
ld r12 ,P A C A _ E X S L B + E X _ R 1 2 ( r13 )
ld r13 ,P A C A _ E X S L B + E X _ R 1 3 ( r13 )
rfid
b . / * p r e v e n t s p e c u l a t i v e e x e c u t i o n * /
2012-11-02 10:21:43 +04:00
/* Equivalents to the above handlers for relocation-on interrupt vectors */
STD_ R E L O N _ E X C E P T I O N _ H V ( . , 0 x e 0 0 , h _ d a t a _ s t o r a g e )
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x e 0 0 )
STD_ R E L O N _ E X C E P T I O N _ H V ( . , 0 x e 2 0 , h _ i n s t r _ s t o r a g e )
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x e 2 0 )
STD_ R E L O N _ E X C E P T I O N _ H V ( . , 0 x e 4 0 , e m u l a t i o n _ a s s i s t )
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x e 4 0 )
STD_ R E L O N _ E X C E P T I O N _ H V ( . , 0 x e 6 0 , h m i _ e x c e p t i o n )
KVM_ H A N D L E R ( P A C A _ E X G E N , E X C _ H V , 0 x e 6 0 )
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( . , 0 x f00 , p e r f o r m a n c e _ m o n i t o r )
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( . , 0 x f20 , a l t i v e c _ u n a v a i l a b l e )
STD_ R E L O N _ E X C E P T I O N _ P S E R I E S ( . , 0 x f40 , v s x _ u n a v a i l a b l e )
2011-09-19 21:45:04 +04:00
# if d e f i n e d ( C O N F I G _ P P C _ P S E R I E S ) | | d e f i n e d ( C O N F I G _ P P C _ P O W E R N V )
2009-06-03 01:17:38 +04:00
/ *
* Data a r e a r e s e r v e d f o r F W N M I o p t i o n .
* This a d d r e s s ( 0 x70 0 0 ) i s f i x e d b y t h e R P A .
* /
. = 0 x7 0 0 0
.globl fwnmi_data_area
fwnmi_data_area :
2011-09-19 21:45:04 +04:00
/ * pseries a n d p o w e r n v n e e d t o k e e p t h e w h o l e p a g e f r o m
* 0 x7 0 0 0 t o 0 x80 0 0 f r e e f o r u s e b y t h e f i r m w a r e
* /
2012-11-02 07:11:51 +04:00
. = 0 x8 0 0 0
2011-09-19 21:45:04 +04:00
# endif / * d e f i n e d ( C O N F I G _ P P C _ P S E R I E S ) | | d e f i n e d ( C O N F I G _ P P C _ P O W E R N V ) * /
2011-03-06 21:09:07 +03:00
2012-02-28 06:44:58 +04:00
/* Space for CPU0's segment table */
.balign 4096
2011-03-06 21:09:07 +03:00
.globl initial_stab
initial_stab :
.space 4096
2012-02-28 06:44:58 +04:00
2011-09-19 21:45:04 +04:00
# ifdef C O N F I G _ P P C _ P O W E R N V
_ GLOBAL( o p a l _ m c _ s e c o n d a r y _ h a n d l e r )
HMT_ M E D I U M
SET_ S C R A T C H 0 ( r13 )
GET_ P A C A ( r13 )
clrldi r3 ,r3 ,2
tovirt( r3 ,r3 )
std r3 ,P A C A _ O P A L _ M C _ E V T ( r13 )
ld r13 ,O P A L _ M C _ S R R 0 ( r3 )
mtspr S P R N _ S R R 0 ,r13
ld r13 ,O P A L _ M C _ S R R 1 ( r3 )
mtspr S P R N _ S R R 1 ,r13
ld r3 ,O P A L _ M C _ G P R 3 ( r3 )
GET_ S C R A T C H 0 ( r13 )
b m a c h i n e _ c h e c k _ p S e r i e s
# endif / * C O N F I G _ P P C _ P O W E R N V * /