[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOFt0_ANW6uHVU4+bTP8=oXJ8OjsEiuFPkz3GCcTZFLHs5xo4A@mail.gmail.com>
Date: Mon, 28 Sep 2015 11:54:14 +0100
From: Alex Smith <alex@...x-smith.me.uk>
To: Markos Chandras <markos.chandras@...tec.com>
Cc: linux-mips <linux-mips@...ux-mips.org>,
Alex Smith <alex.smith@...tec.com>,
linux-kernel@...r.kernel.org,
Matthew Fortune <matthew.fortune@...tec.com>
Subject: Re: [PATCH 1/3] MIPS: Initial implementation of a VDSO
Hi Markos,
Thanks for finishing this off. Just got a few of minor comments.
On 28 September 2015 at 11:10, Markos Chandras
<markos.chandras@...tec.com> wrote:
> diff --git a/arch/mips/vdso/elf.S b/arch/mips/vdso/elf.S
> new file mode 100644
> index 000000000000..60c23d0d452c
> --- /dev/null
> +++ b/arch/mips/vdso/elf.S
> @@ -0,0 +1,68 @@
> +/*
> + * Copyright (C) 2015 Imagination Technologies
> + * Author: Alex Smith <alex.smith@...tec.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2 of the License, or (at your
> + * option) any later version.
> + */
> +
> +#include "vdso.h"
> +
> +#include <linux/elfnote.h>
> +#include <linux/version.h>
> +
> +ELFNOTE_START(Linux, 0, "a")
> + .long LINUX_VERSION_CODE
> +ELFNOTE_END
> +
> +/*
> + * The .MIPS.abiflags section must be defined with the FP ABI flags set
> + * to 'any' to be able to link with both old and new libraries.
> + * Newer toolchains are capable of automatically generating this, but we want
> + * to work with older toolchains as well. Therefore, we define the contents of
> + * this section here (under different names), and then genvdso will patch
> + * it to have the correct name and type.
> + *
> + * We base the .MIPS.abiflags section on preprocessor definitions rather than
> + * CONFIG_* because we need to match the particular ABI we are building the
> + * VDSO for.
> + *
> + * See https://dmz-portal.mips.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking
> + * for the .MIPS.abitflags and .gnu.attributes section description.
> + */
s/abitflags/abiflags/
> diff --git a/arch/mips/vdso/vdso.h b/arch/mips/vdso/vdso.h
> new file mode 100644
> index 000000000000..64b98967e245
> --- /dev/null
> +++ b/arch/mips/vdso/vdso.h
> @@ -0,0 +1,79 @@
> +/*
> + * Copyright (C) 2015 Imagination Technologies
> + * Author: Alex Smith <alex.smith@...tec.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2 of the License, or (at your
> + * option) any later version.
> + */
> +
> +#include <asm/sgidefs.h>
> +
> +#if _MIPS_SIM != _MIPS_SIM_ABI64 && defined(CONFIG_64BIT)
> +
> +/* Building 32-bit VDSO for the 64-bit kernel. Fake a 32-bit Kconfig. */
> +#undef CONFIG_64BIT
> +#define CONFIG_32BIT 1
> +
> +#endif
> +
> +#ifndef __ASSEMBLY__
> +
> +#include <asm/asm.h>
> +#include <asm/page.h>
> +#include <asm/vdso.h>
> +
> +static inline unsigned long get_vdso_base(void)
> +{
> + unsigned long addr;
> +
> + /*
> + * Get the base load address of the VDSO. We have to avoid generating
> + * relocations and references to the GOT because ld.so does not peform
> + * relocations on the VDSO. We use the current offset from the VDSO base
> + * and perform a PC-relative branch which gives the absolute address in
> + * ra, and take the difference. The assembler chokes on
> + * "li %0, _start - .", so embed the offset as a word and branch over
> + * it.
> + *
> + * TODO: Is there a better way to do this?
Unless somebody else can come up with a better way to do this I'd say
this TODO can go :)
Also perhaps move the description of what the code is doing (from "We
use the current offset from the VDSO base" onwards) down to after the
#else since it applies to that code rather than the R6 code which
comes first.
> + */
> +
> +#ifdef CONFIG_CPU_MIPSR6
> + /*
> + * We can't use cpu_has_mips_r6 since it will create a relocation
> + * in the VDSO because of the global cpu_data[] variable.
> + */
I think it would be more correct to say here that cpu_data doesn't
even exist to the VDSO because it's a kernel symbol.
> +
> + /* lapc <symbol> is an alias to addiupc reg, <symbol> - .
> + *
> + * We can't use addiupc because there is no label-label
> + * support for the addiupc reloc
> + */
> + __asm__("lapc %0, _start \n"
> + : "=r" (addr) : :);
Just curious - if lapc is just an alias to addiupc, why does that work
but not addiupc? IIRC I did try addiupc previously but removed it
because it wasn't working, didn't know about lapc!
Thanks,
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists