From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 05/23] Add common PPC64 KVM asm helpers
Date: Wed, 08 Jul 2009 04:17:56 +0000 [thread overview]
Message-ID: <1247026676.6066.81.camel@pasglop> (raw)
In-Reply-To: <1246976262-4826-6-git-send-email-agraf@suse.de>
On Tue, 2009-07-07 at 16:17 +0200, Alexander Graf wrote:
> +.macro to_phys dest_reg, source_reg
> +#if PAGE_OFFSET = 0xc000000000000000
> + clrldi \dest_reg, \source_reg, 2
> +#else
> + #error Unknown PAGE_OFFSET
> +#endif
We already have tophys() for that in ppc_asm.h
BTW. We prefer using C-style #define for asm macros ... bad habit maybe
but at least it's consistent :-)
> +.endm
> +
> +.macro loadimm reg, imm
> + lis \reg, \imm@highest
> + ori \reg, \reg, \imm@higher
> + rldicr \reg, \reg, 32, 31
> + oris \reg, \reg, \imm@h
> + ori \reg, \reg, \imm@l
> +.endm
We already have LOAD_REG_IMMEDIATE() in ppc_asm.h :-)
> +.macro setmagc reg
> + ori \reg, r13, 1 /* r3 = PACA | 1 */
> + mtspr SPRN_SPRG3, \reg /* SPRG3 =PACA | 1 */
> +.endm
Fun :-) So you set the PACA low bit to indicate you are running in the
guest ? That's a pretty good way to do it I suppose.
> +#define HOST_STACK_R1 (0 * ULONG_SIZE)
> +/* We need to keep some space here that the C function */
> +/* we jump into later can clobber */
> +#define HOST_STACK_LR (8 * ULONG_SIZE)
> +#define HOST_STACK_RUN (9 * ULONG_SIZE)
> +#define HOST_STACK_VCPU (10 * ULONG_SIZE)
> +#define HOST_STACK_R14 (14 * ULONG_SIZE)
> +#define HOST_STACK_R15 (15 * ULONG_SIZE)
> +#define HOST_STACK_R16 (16 * ULONG_SIZE)
> +#define HOST_STACK_R17 (17 * ULONG_SIZE)
> +#define HOST_STACK_R18 (18 * ULONG_SIZE)
> +#define HOST_STACK_R19 (19 * ULONG_SIZE)
> +#define HOST_STACK_R20 (20 * ULONG_SIZE)
> +#define HOST_STACK_R21 (21 * ULONG_SIZE)
> +#define HOST_STACK_R22 (22 * ULONG_SIZE)
> +#define HOST_STACK_R23 (23 * ULONG_SIZE)
> +#define HOST_STACK_R24 (24 * ULONG_SIZE)
> +#define HOST_STACK_R25 (25 * ULONG_SIZE)
> +#define HOST_STACK_R26 (26 * ULONG_SIZE)
> +#define HOST_STACK_R27 (27 * ULONG_SIZE)
> +#define HOST_STACK_R28 (28 * ULONG_SIZE)
> +#define HOST_STACK_R29 (29 * ULONG_SIZE)
> +#define HOST_STACK_R30 (30 * ULONG_SIZE)
> +#define HOST_STACK_R31 (31 * ULONG_SIZE)
> +#define HOST_STACK_MIN_SIZE (HOST_STACK_R31 + ULONG_SIZE)
> +#define HOST_STACK_SIZE (((HOST_STACK_MIN_SIZE + 15) / 16) * 16) /* Align. */
> +#define VCPU_GPR(n) (VCPU_GPRS + (n * ULONG_SIZE))
Can't you define a C structure and generate offsets in asm-offsets.h
using asm-offsets.c like we do for most other stuff ?
Cheers,
Ben.
> +.macro mfpaca tmp_reg, src_reg, offset, vcpu_reg
> + ld \tmp_reg, (PACA_EXMC+\offset)(r13)
> + std \tmp_reg, VCPU_GPR(\src_reg)(\vcpu_reg)
> +.endm
> +
> +
> +.macro DO_KVM intno
> + .if (\intno = PPC970_INTERRUPT_SYSTEM_RESET) || \
> + (\intno = PPC970_INTERRUPT_MACHINE_CHECK) || \
> + (\intno = PPC970_INTERRUPT_DATA_STORAGE) || \
> + (\intno = PPC970_INTERRUPT_INST_STORAGE) || \
> + (\intno = PPC970_INTERRUPT_DATA_SEGMENT) || \
> + (\intno = PPC970_INTERRUPT_INST_SEGMENT) || \
> + (\intno = PPC970_INTERRUPT_EXTERNAL) || \
> + (\intno = PPC970_INTERRUPT_ALIGNMENT) || \
> + (\intno = PPC970_INTERRUPT_PROGRAM) || \
> + (\intno = PPC970_INTERRUPT_FP_UNAVAIL) || \
> + (\intno = PPC970_INTERRUPT_DECREMENTER) || \
> + (\intno = PPC970_INTERRUPT_SYSCALL) || \
> + (\intno = PPC970_INTERRUPT_TRACE) || \
> + (\intno = PPC970_INTERRUPT_PERFMON) || \
> + (\intno = PPC970_INTERRUPT_ALTIVEC) || \
> + (\intno = PPC970_INTERRUPT_VSX)
> +
> + b kvmppc_trampoline_\intno
> +kvmppc_resume_\intno:
> +
> + .endif
> +.endm
> +
> +#else
> +
> +.macro DO_KVM intno
> +.endm
> +
> +#endif /* CONFIG_KVM_970_HANDLER */
> +
> +#endif /* __ASM_KVM_970_ASM_H__ */
next prev parent reply other threads:[~2009-07-08 4:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-07 14:17 [PATCH 05/23] Add common PPC64 KVM asm helpers Alexander Graf
2009-07-08 4:17 ` Benjamin Herrenschmidt [this message]
2009-07-08 6:53 ` Alexander Graf
2009-07-08 6:59 ` Alexander Graf
2009-07-08 7:07 ` Benjamin Herrenschmidt
2009-07-08 7:08 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1247026676.6066.81.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=kvm-ppc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox