On 08.07.2009, at 06:17, Benjamin Herrenschmidt wrote:
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
Heh - looks like I reimplemented the wheel :-)
BTW. We prefer using C-style #define for asm macros ... bad habit
maybe
but at least it's consistent :-)
Hum. I personally prefer to have assembly code look like assembly
code. Guess it's a matter of personal taste.
+.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.
Yeah, this is about the most clever way to do it I found. MOL stores a
magic value in an SPRG IIRC, which I did too at first, but then I run
out of free SPRGs in the handler code.
+#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 ?
You define the stack in a struct? I also don't see why I should have
31 single #defines when all I really need is simply packed in an easy
algorithm.
Basically VCPU_GPR points to an index of a C defined array.
Alex
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html