2019-08-14 00:33:19 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Atmosphère-NX
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
2020-01-02 18:41:52 +00:00
|
|
|
#include <stdio.h>
|
2019-08-14 00:33:19 +02:00
|
|
|
#include "data_abort.h"
|
|
|
|
#include "sysreg.h"
|
|
|
|
#include "debug_log.h"
|
|
|
|
#include "irq.h"
|
2019-08-18 00:40:47 +02:00
|
|
|
#include "vgic.h"
|
2019-08-14 00:33:19 +02:00
|
|
|
|
|
|
|
// Lower el
|
|
|
|
|
|
|
|
void dumpUnhandledDataAbort(DataAbortIss dabtIss, u64 far, const char *msg)
|
|
|
|
{
|
2020-01-02 18:41:52 +00:00
|
|
|
char s1[64], s2[32], s3[64] = "";
|
|
|
|
(void)s1; (void)s2; (void)s3;
|
2020-01-17 22:10:26 +00:00
|
|
|
sprintf(s1, "Unhandled%s %s", msg , dabtIss.wnr ? "write" : "read");
|
2019-08-14 00:33:19 +02:00
|
|
|
if (dabtIss.fnv) {
|
2020-01-02 18:41:52 +00:00
|
|
|
sprintf(s2, "<unk>");
|
2019-08-14 00:33:19 +02:00
|
|
|
} else {
|
2020-01-02 18:41:52 +00:00
|
|
|
sprintf(s2, "%016lx", far);
|
2019-08-14 00:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dabtIss.isv) {
|
2020-01-02 18:41:52 +00:00
|
|
|
sprintf(s3, ", size %u Rt=%u", BIT(dabtIss.sas), dabtIss.srt);
|
2019-08-14 00:33:19 +02:00
|
|
|
}
|
|
|
|
|
2020-01-02 18:41:52 +00:00
|
|
|
DEBUG("%s at %s%s\n", s1, s2, s3);
|
2019-08-14 00:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void handleLowerElDataAbortException(ExceptionStackFrame *frame, ExceptionSyndromeRegister esr)
|
|
|
|
{
|
|
|
|
DataAbortIss dabtIss;
|
2019-12-23 20:12:02 +00:00
|
|
|
u32 iss = esr.iss;
|
|
|
|
memcpy(&dabtIss, &iss, 4);
|
2019-08-14 00:33:19 +02:00
|
|
|
|
|
|
|
u64 far = GET_SYSREG(far_el2);
|
2019-08-14 15:48:07 +02:00
|
|
|
u64 farpg = far & ~0xFFFull;
|
2019-08-14 00:33:19 +02:00
|
|
|
|
|
|
|
if (!dabtIss.isv || dabtIss.fnv) {
|
|
|
|
dumpUnhandledDataAbort(dabtIss, far, "");
|
|
|
|
}
|
|
|
|
|
2020-01-17 22:10:26 +00:00
|
|
|
if (farpg == MEMORY_MAP_PA_GICD) {
|
2019-08-18 00:40:47 +02:00
|
|
|
handleVgicdMmio(frame, dabtIss, far & 0xFFF);
|
2020-01-17 22:10:26 +00:00
|
|
|
} else if (farpg == MEMORY_MAP_PA_GICH) {
|
|
|
|
dumpUnhandledDataAbort(dabtIss, far, " GICH");
|
2019-08-14 15:48:07 +02:00
|
|
|
} else {
|
2020-01-17 22:10:26 +00:00
|
|
|
dumpUnhandledDataAbort(dabtIss, far, "");
|
2019-08-14 00:33:19 +02:00
|
|
|
}
|
2019-12-23 20:12:02 +00:00
|
|
|
|
2020-01-17 22:10:26 +00:00
|
|
|
// Skip instruction anyway
|
2019-12-23 20:12:02 +00:00
|
|
|
skipFaultingInstruction(frame, esr.il == 0 ? 2 : 4);
|
2019-08-18 00:40:47 +02:00
|
|
|
}
|