Check-in [3437cabeb6]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Turn MEM_MARK_INVALID into MEM_SET_INT; Add fallback for MEM_SET and MEM_SET_INT
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3437cabeb6943668a7c00a9e37dcb6404ac3e283
User & Date: stephanie.gawroriski 2019-06-16 15:52:01
Context
2019-06-16
17:11
Add virtual pointers for 64-bit RatufaCoat which virtualizes some memory. check-in: f612155ba9 user: stephanie.gawroriski tags: trunk
15:52
Turn MEM_MARK_INVALID into MEM_SET_INT; Add fallback for MEM_SET and MEM_SET_INT check-in: 3437cabeb6 user: stephanie.gawroriski tags: trunk
15:27
Remove extra C file. check-in: 7413ca5b27 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ratufacoat/sjmerc.c.

1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
		nextpc = cpu->pc;
		
		/* Read operation and determine encoding. */
		op = (sjme_memjreadp(jvm, 1, &nextpc) & SJME_JINT_C(0xFF));
		enc = ((op >= SJME_ENC_SPECIAL_A) ? op : (op & SJME_ENC_MASK));
		
		/* Temporary debug. */
#if 0
		fprintf(stderr,
			"ti=%d pc=%p op=%X cl=%s mn=%s mt=%s ln=%d jo=%x ja=%d\n",
			jvm->totalinstructions,
			cpu->pc,
			(unsigned int)op,
			(cpu->debugclassname == NULL ? NULL :
				SJME_POINTER_OFFSET(cpu->debugclassname, 2)),







|







1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
		nextpc = cpu->pc;
		
		/* Read operation and determine encoding. */
		op = (sjme_memjreadp(jvm, 1, &nextpc) & SJME_JINT_C(0xFF));
		enc = ((op >= SJME_ENC_SPECIAL_A) ? op : (op & SJME_ENC_MASK));
		
		/* Temporary debug. */
#if 1
		fprintf(stderr,
			"ti=%d pc=%p op=%X cl=%s mn=%s mt=%s ln=%d jo=%x ja=%d\n",
			jvm->totalinstructions,
			cpu->pc,
			(unsigned int)op,
			(cpu->debugclassname == NULL ? NULL :
				SJME_POINTER_OFFSET(cpu->debugclassname, 2)),

Changes to runt/apis/cldc-compact/cc/squirreljme/jvm/SystemCallIndex.java.

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	public static final short PD_WRITE_BYTE =
		16;
	
	/** Set memory. */
	public static final short MEM_SET =
		17;
	
	/** Mark memory as invalid. */
	public static final short MEM_MARK_INVALID =
		18;
	
	/** System call count. */
	public static final short NUM_SYSCALLS =
		19;
	
	/**







|
|







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	public static final short PD_WRITE_BYTE =
		16;
	
	/** Set memory. */
	public static final short MEM_SET =
		17;
	
	/** Set memory but in 4-byte pattern. */
	public static final short MEM_SET_INT =
		18;
	
	/** System call count. */
	public static final short NUM_SYSCALLS =
		19;
	
	/**

Changes to runt/klib/supervisor/cc/squirreljme/jvm/Allocator.java.

99
100
101
102
103
104
105








106
107
108
109
110
111
112
...
139
140
141
142
143
144
145
146
147
148
149


150
151
152
153
154
155
156
157
158
159
160
161


162
163
164
165
166
167
168
169
170
171
				// The size of our current chunk is the wanted size
				Assembly.memWriteInt(seeker, CHUNK_SIZE_OFFSET,
					want);
				
				// Clear out memory since Java expects the data to be
				// initialized to zero always
				Assembly.sysCallP(SystemCallIndex.MEM_SET, rv, 0, __sz);








				
				// Use this chunk
				return rv;
			}
			
			// Go to the next chunk
			seeker = cnx;
................................................................................
			Assembly.breakpoint();
		
		// Set as free
		Assembly.memWriteInt(seeker, CHUNK_SIZE_OFFSET,
			csz | MEMPART_FREE_BIT);
		
		// Parameters used for memory corruption
		int i = CHUNK_LENGTH,
			bm = Constants.BAD_MAGIC,
			rci = CHUNK_LENGTH + Constants.OBJECT_COUNT_OFFSET;
		


		// Corrupt anything up to the reference count index
		for (; i < rci; i+= 4)
			Assembly.memWriteInt(seeker, i, bm);
		
		// Make sure the reference count index is zero, to detect uncount
		// after free
		if (i < csz)
		{
			Assembly.memWriteInt(seeker, i, 0);
			i += 4;
		}
		


		// Then just wipe the remaining memory
		for (; i < csz; i+= 4)
			Assembly.memWriteInt(seeker, i, bm);
	}
	
	/**
	 * Initializes the RAM links.
	 *
	 * @param __rambase The base of RAM.
	 * @param __ramsize The amount of RAM available.







>
>
>
>
>
>
>
>







 







<
|
<

>
>
|
|
|
|
|
|
|
<
|
<


>
>
|
|
|







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
147
148
149
150
151
152
153

154

155
156
157
158
159
160
161
162
163
164

165

166
167
168
169
170
171
172
173
174
175
176
177
178
179
				// The size of our current chunk is the wanted size
				Assembly.memWriteInt(seeker, CHUNK_SIZE_OFFSET,
					want);
				
				// Clear out memory since Java expects the data to be
				// initialized to zero always
				Assembly.sysCallP(SystemCallIndex.MEM_SET, rv, 0, __sz);
				if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
					SystemCallIndex.MEM_SET) != SystemCallError.NO_ERROR)
				{
					// Fast memset() is not supported, so manually wipe
					// all the bytes!
					for (int i = CHUNK_LENGTH; i < want; i += 4)
						Assembly.memWriteInt(seeker, i, 0);
				}
				
				// Use this chunk
				return rv;
			}
			
			// Go to the next chunk
			seeker = cnx;
................................................................................
			Assembly.breakpoint();
		
		// Set as free
		Assembly.memWriteInt(seeker, CHUNK_SIZE_OFFSET,
			csz | MEMPART_FREE_BIT);
		
		// Parameters used for memory corruption

		int bm = Constants.BAD_MAGIC;

		
		// Clear out memory with invalid data, that is BAD_MAGIC
		Assembly.sysCallP(SystemCallIndex.MEM_SET_INT, __p, bm,
			csz - CHUNK_LENGTH);
		if (Assembly.sysCallPV(SystemCallIndex.ERROR_GET,
			SystemCallIndex.MEM_SET_INT) != SystemCallError.NO_ERROR)
		{
			// Fast memsetint() is not supported, so manually wipe
			// all the bytes!
			for (int i = CHUNK_LENGTH; i < csz; i += 4)

				Assembly.memWriteInt(seeker, i, bm);

		}
		
		// Make sure the reference count index is zero, to detect uncount
		// after free
		int rci = CHUNK_LENGTH + Constants.OBJECT_COUNT_OFFSET;
		if (rci + 4 <= csz)
			Assembly.memWriteInt(seeker, rci, 0);
	}
	
	/**
	 * Initializes the RAM links.
	 *
	 * @param __rambase The base of RAM.
	 * @param __ramsize The amount of RAM available.

Changes to runt/klib/supervisor/cc/squirreljme/jvm/SystemCallIndex.java.

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	public static final short PD_WRITE_BYTE =
		16;
	
	/** Set memory. */
	public static final short MEM_SET =
		17;
	
	/** Mark memory as invalid. */
	public static final short MEM_MARK_INVALID =
		18;
	
	/** System call count. */
	public static final short NUM_SYSCALLS =
		19;
	
	/**







|
|







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	public static final short PD_WRITE_BYTE =
		16;
	
	/** Set memory. */
	public static final short MEM_SET =
		17;
	
	/** Set memory but in 4-byte pattern. */
	public static final short MEM_SET_INT =
		18;
	
	/** System call count. */
	public static final short NUM_SYSCALLS =
		19;
	
	/**