-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arm64/mte: Add support for arm64 mte
Signed-off-by: wangmingrong1 <[email protected]>
- Loading branch information
Showing
10 changed files
with
184 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/**************************************************************************** | ||
* arch/arm64/src/common/arm64_mte.c | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. The | ||
* ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Included Files | ||
****************************************************************************/ | ||
|
||
#include <nuttx/config.h> | ||
|
||
#include <assert.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
|
||
#include "arm64_arch.h" | ||
|
||
/**************************************************************************** | ||
* Pre-processor Definitions | ||
****************************************************************************/ | ||
|
||
#define GCR_EL1_VAL 0x10001 | ||
|
||
/**************************************************************************** | ||
* Private Functions | ||
****************************************************************************/ | ||
|
||
static int arm64_mte_is_support(void) | ||
{ | ||
int supported; | ||
__asm__ volatile ( | ||
"mrs %0, ID_AA64PFR1_EL1\n" | ||
"ubfx %0, %0, #8, #3\n" | ||
: "=r" (supported) | ||
: | ||
: "memory" | ||
); | ||
return supported != 0; | ||
} | ||
|
||
/**************************************************************************** | ||
* Public Functions | ||
****************************************************************************/ | ||
|
||
void arm64_enable_mte(void) | ||
{ | ||
uint64_t val; | ||
|
||
if (!arm64_mte_is_support()) | ||
{ | ||
return; | ||
} | ||
|
||
assert(!(read_sysreg(ttbr0_el1) & TTBR_CNP_BIT)); | ||
assert(!(read_sysreg(ttbr1_el1) & TTBR_CNP_BIT)); | ||
|
||
val = read_sysreg(sctlr_el1); | ||
val |= SCTLR_ATA_BIT | SCTLR_TCF1_BIT; | ||
write_sysreg(val, sctlr_el1); | ||
|
||
write_sysreg(GCR_EL1_VAL, gcr_el1); | ||
|
||
val = (read_sysreg(CNTVCT_EL0) & RGSR_EL1_SEED_MASK) << | ||
RGSR_EL1_SEED_SHIFT; | ||
|
||
if (0 == val) | ||
{ | ||
val = 1 << RGSR_EL1_SEED_SHIFT; | ||
} | ||
|
||
write_sysreg(val, rgsr_el1); | ||
|
||
write_sysreg(0, tfsr_el1); | ||
write_sysreg(0, tfsre0_el1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters