Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1174766 > unrolled thread

[PATCH 4/4] hvc_dcc: disable user-space access to DCC

Started byTimur Tabi <timur@codeaurora.org>
First post2015-06-30 23:30 +0200
Last post2015-07-03 17:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 4/4] hvc_dcc: disable user-space access to DCC Timur Tabi <timur@codeaurora.org> - 2015-06-30 23:30 +0200
    Re: [PATCH 4/4] hvc_dcc: disable user-space access to DCC Stephen Boyd <sboyd@codeaurora.org> - 2015-07-02 02:10 +0200
      Re: [PATCH 4/4] hvc_dcc: disable user-space access to DCC Timur Tabi <timur@codeaurora.org> - 2015-07-03 17:00 +0200

#1174766 — [PATCH 4/4] hvc_dcc: disable user-space access to DCC

FromTimur Tabi <timur@codeaurora.org>
Date2015-06-30 23:30 +0200
Subject[PATCH 4/4] hvc_dcc: disable user-space access to DCC
Message-ID<pHbgm-5xn-5@gated-at.bofh.it>
If the DCC driver loads, then disable user-space access to the DCC so that
we don't have two entities trying to access the DCC at the same time.

Signed-off-by: Timur Tabi <timur@codeaurora.org>
---
 arch/arm/include/asm/dcc.h   | 15 +++++++++++++++
 arch/arm64/include/asm/dcc.h | 11 +++++++++++
 drivers/tty/hvc/hvc_dcc.c    |  2 ++
 3 files changed, 28 insertions(+)

diff --git a/arch/arm/include/asm/dcc.h b/arch/arm/include/asm/dcc.h
index b74899d..c50056b 100644
--- a/arch/arm/include/asm/dcc.h
+++ b/arch/arm/include/asm/dcc.h
@@ -9,8 +9,11 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
+#ifndef __ASM_DCC_H
+#define __ASM_DCC_H
 
 #include <asm/barrier.h>
+#include <asm/hardware/cp14.h>
 
 static inline u32 __dcc_getstatus(void)
 {
@@ -39,3 +42,15 @@ static inline void __dcc_putchar(char c)
 		: "r" (c));
 	isb();
 }
+
+static inline void __dcc_initialize(void)
+{
+	u32 val;
+
+	/* Disable user-space access to DCC */
+	val = MRC14(0, c0, c1, 0);
+	val |= 1 << 12; /* DSCR[Comms] */
+	MCR14(val, 0, c0, c1, 0);
+}
+
+#endif
diff --git a/arch/arm64/include/asm/dcc.h b/arch/arm64/include/asm/dcc.h
index fcb8d7d..7843e62 100644
--- a/arch/arm64/include/asm/dcc.h
+++ b/arch/arm64/include/asm/dcc.h
@@ -49,4 +49,15 @@ static inline void __dcc_putchar(char c)
 	isb();
 }
 
+static inline void __dcc_initialize(void)
+{
+	u32 val;
+
+	/* Disable user-space access to DCC */
+	asm ("mrs %0, mdscr_el1\n"
+		"	orr %0, %0, #4096\n" /* Set the TDCC bit */
+		"	msr mdscr_el1, %0\n"
+		: "=r" (val));
+}
+
 #endif
diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c
index f8b8cf2..5ccafa4 100644
--- a/drivers/tty/hvc/hvc_dcc.c
+++ b/drivers/tty/hvc/hvc_dcc.c
@@ -231,6 +231,8 @@ static int __init hvc_dcc_console_init(void)
 	if (!hvc_dcc_check())
 		return -ENODEV;
 
+	__dcc_initialize();
+
 	/* Returns -1 if error */
 	ret = hvc_instantiate(0, 0, &hvc_dcc_get_put_ops);
 
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1175620

FromStephen Boyd <sboyd@codeaurora.org>
Date2015-07-02 02:10 +0200
Message-ID<pHAeJ-3Ll-1@gated-at.bofh.it>
In reply to#1174766
On 06/30/2015 02:23 PM, Timur Tabi wrote:
> diff --git a/arch/arm/include/asm/dcc.h b/arch/arm/include/asm/dcc.h
> index b74899d..c50056b 100644
> --- a/arch/arm/include/asm/dcc.h
> +++ b/arch/arm/include/asm/dcc.h
> @@ -9,8 +9,11 @@
>   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>   * GNU General Public License for more details.
>   */
> +#ifndef __ASM_DCC_H
> +#define __ASM_DCC_H
>  
>  #include <asm/barrier.h>
> +#include <asm/hardware/cp14.h>

That's new.

>  
>  static inline u32 __dcc_getstatus(void)
>  {
> @@ -39,3 +42,15 @@ static inline void __dcc_putchar(char c)
>  		: "r" (c));
>  	isb();
>  }
> +
> +static inline void __dcc_initialize(void)
> +{
> +	u32 val;
> +
> +	/* Disable user-space access to DCC */
> +	val = MRC14(0, c0, c1, 0);
> +	val |= 1 << 12; /* DSCR[Comms] */
> +	MCR14(val, 0, c0, c1, 0);
> +}

Nitpick: We do raw cp14 accesses for other functions in this file, so it
would be nice to be consistent throughout.

> +
> +#endif
> diff --git a/arch/arm64/include/asm/dcc.h b/arch/arm64/include/asm/dcc.h
> index fcb8d7d..7843e62 100644
> --- a/arch/arm64/include/asm/dcc.h
> +++ b/arch/arm64/include/asm/dcc.h
> @@ -49,4 +49,15 @@ static inline void __dcc_putchar(char c)
>  	isb();
>  }
>  
> +static inline void __dcc_initialize(void)
> +{
> +	u32 val;
> +
> +	/* Disable user-space access to DCC */
> +	asm ("mrs %0, mdscr_el1\n"

shouldn't this be volatile?

> +		"	orr %0, %0, #4096\n" /* Set the TDCC bit */

arm64 has some #defines in debug-monitors.h which we should probably
extend to have this bit as a #define too.

> +		"	msr mdscr_el1, %0\n"
> +		: "=r" (val));
> +}
> +
>  #endif
>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1176643

FromTimur Tabi <timur@codeaurora.org>
Date2015-07-03 17:00 +0200
Message-ID<pIaBA-1kt-13@gated-at.bofh.it>
In reply to#1175620
On Jul 1, 2015, at 8:00 PM, Stephen Boyd wrote:

>> 
>> #include <asm/barrier.h>
>> +#include <asm/hardware/cp14.h>
> 
> That's new.

And no one else is using it either.

>> 
>> +
>> +static inline void __dcc_initialize(void)
>> +{
>> +	u32 val;
>> +
>> +	/* Disable user-space access to DCC */
>> +	val = MRC14(0, c0, c1, 0);
>> +	val |= 1 << 12; /* DSCR[Comms] */
>> +	MCR14(val, 0, c0, c1, 0);
>> +}
> 
> Nitpick: We do raw cp14 accesses for other functions in this file, so it
> would be nice to be consistent throughout.

I agree, but I didn't want to expand the scope of this patch beyond what it's supposed to do.

>> 
>> +static inline void __dcc_initialize(void)
>> +{
>> +	u32 val;
>> +
>> +	/* Disable user-space access to DCC */
>> +	asm ("mrs %0, mdscr_el1\n"
> 
> shouldn't this be volatile?

Well, I figured it wasn't important exactly why these instructions are executed, since it just disables user-space.  I usually get chewed out by someone if I add volatile where it's not needed, so I didn't add it this time.

> 
>> +		"	orr %0, %0, #4096\n" /* Set the TDCC bit */
> 
> arm64 has some #defines in debug-monitors.h which we should probably
> extend to have this bit as a #define too.

Hmmm, the only thing I see in debug_monitors.h that seems applicable are the mdscr_write() and mdscr_read() functions, which seem to overlap cp14.h.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web