mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-06 15:42:38 -05:00
Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d82e100e30 | ||
|
|
5f869a414c | ||
|
|
7fd6be7d83 | ||
|
|
ae6c536e98 | ||
|
|
c66c593123 | ||
|
|
b3788b2ba3 | ||
|
|
b7adb34c37 | ||
|
|
ace8409a56 | ||
|
|
e2c757d9dd | ||
|
|
da35de993f | ||
|
|
854b7618ef | ||
|
|
3477f9fbc1 | ||
|
|
5799744f2f | ||
|
|
61d165a314 | ||
|
|
69186f2470 | ||
|
|
730d4a6cee | ||
|
|
54bc91d5e3 | ||
|
|
5f9e0ebc6c | ||
|
|
f314c69a70 | ||
|
|
16fe462cad | ||
|
|
e6e2987ddf | ||
|
|
ed456b02cf | ||
|
|
da7f5826cb | ||
|
|
6cb398bb42 | ||
|
|
748be760e8 | ||
|
|
4a4118bb8e | ||
|
|
77f1bf0861 | ||
|
|
6bb29b3e7b | ||
|
|
f720772338 | ||
|
|
e53e48b88c | ||
|
|
ecf36ee891 | ||
|
|
23ef949dd3 | ||
|
|
92e708c6e7 | ||
|
|
30cfcc27db | ||
|
|
3c6077fb02 | ||
|
|
63883b4fa7 | ||
|
|
0f83b5e06c | ||
|
|
637a333197 | ||
|
|
3171b06048 | ||
|
|
2a66a0fa2f | ||
|
|
c080d5b962 | ||
|
|
0133107f14 | ||
|
|
253e349ef9 | ||
|
|
5126cc1414 | ||
|
|
ea1245026d | ||
|
|
2158adb711 | ||
|
|
8554bb4d9c | ||
|
|
1741354498 | ||
|
|
866e97efcf | ||
|
|
277352d072 | ||
|
|
8cae605e1f | ||
|
|
59c85eaf6a | ||
|
|
864233c110 | ||
|
|
e9b32b3009 | ||
|
|
ec608bbd05 | ||
|
|
ec2793bcc9 | ||
|
|
eb40f07552 | ||
|
|
28f268aeba | ||
|
|
bad5458d40 | ||
|
|
b72e21fc3c | ||
|
|
d578a3828f | ||
|
|
6c417eb9af | ||
|
|
dc70893e6b | ||
|
|
c5c958743e | ||
|
|
89f2fa6818 | ||
|
|
bcfd9edaa5 | ||
|
|
e0f774d6dd | ||
|
|
955cc366d1 | ||
|
|
bc4f6249be | ||
|
|
0d45600b0e | ||
|
|
2c8f7f692c | ||
|
|
3e41bdc552 | ||
|
|
5b189696d7 | ||
|
|
c6bcea3811 | ||
|
|
900dd13c45 | ||
|
|
2876f17f65 | ||
|
|
b2563ca8a6 | ||
|
|
7c0d60ac68 | ||
|
|
813a1885cb | ||
|
|
54bcf05b1d | ||
|
|
bbea8810a7 | ||
|
|
b6514957f1 |
26
CHANGELOG.md
26
CHANGELOG.md
@@ -1,3 +1,29 @@
|
||||
# v6.12.1
|
||||
- [#2296](https://github.com/xmrig/xmrig/pull/2296) Fixed Zen3 assembly code for `cn/upx2` algorithm.
|
||||
|
||||
# v6.12.0
|
||||
- [#2276](https://github.com/xmrig/xmrig/pull/2276) Added support for Uplexa (`cn/upx2` algorithm).
|
||||
- [#2261](https://github.com/xmrig/xmrig/pull/2261) Show total hashrate if compiled without OpenCL.
|
||||
- [#2289](https://github.com/xmrig/xmrig/pull/2289) RandomX: optimized `IMUL_RCP` instruction.
|
||||
- Added support for `--user` command line option for online benchmark.
|
||||
|
||||
# v6.11.2
|
||||
- [#2207](https://github.com/xmrig/xmrig/issues/2207) Fixed regression in HTTP parser and llhttp updated to v5.1.0.
|
||||
|
||||
# v6.11.1
|
||||
- [#2239](https://github.com/xmrig/xmrig/pull/2239) Fixed broken `coin` setting functionality.
|
||||
|
||||
# v6.11.0
|
||||
- [#2196](https://github.com/xmrig/xmrig/pull/2196) Improved DNS subsystem and added new DNS specific options.
|
||||
- [#2172](https://github.com/xmrig/xmrig/pull/2172) Fixed build on Alpine 3.13.
|
||||
- [#2177](https://github.com/xmrig/xmrig/pull/2177) Fixed ARM specific compilation error with GCC 10.2.
|
||||
- [#2214](https://github.com/xmrig/xmrig/pull/2214) [#2216](https://github.com/xmrig/xmrig/pull/2216) [#2235](https://github.com/xmrig/xmrig/pull/2235) Optimized `cn-heavy` algorithm.
|
||||
- [#2217](https://github.com/xmrig/xmrig/pull/2217) Fixed mining job creation sequence.
|
||||
- [#2225](https://github.com/xmrig/xmrig/pull/2225) Fixed build without OpenCL support on some systems.
|
||||
- [#2229](https://github.com/xmrig/xmrig/pull/2229) Don't use RandomX JIT if `WITH_ASM=OFF`.
|
||||
- [#2228](https://github.com/xmrig/xmrig/pull/2228) Removed useless code for cryptonight algorithms.
|
||||
- [#2234](https://github.com/xmrig/xmrig/pull/2234) Fixed build error on gcc 4.8.
|
||||
|
||||
# v6.10.0
|
||||
- [#2122](https://github.com/xmrig/xmrig/pull/2122) Fixed pause logic when both pause on battery and user activity are enabled.
|
||||
- [#2123](https://github.com/xmrig/xmrig/issues/2123) Fixed compatibility with gcc 4.8.
|
||||
|
||||
@@ -5,6 +5,7 @@ option(WITH_HWLOC "Enable hwloc support" ON)
|
||||
option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON)
|
||||
option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON)
|
||||
option(WITH_CN_PICO "Enable CryptoNight-Pico algorithm" ON)
|
||||
option(WITH_CN_FEMTO "Enable CryptoNight-UPX2 algorithm" ON)
|
||||
option(WITH_RANDOMX "Enable RandomX algorithms family" ON)
|
||||
option(WITH_ARGON2 "Enable Argon2 algorithms family" ON)
|
||||
option(WITH_ASTROBWT "Enable AstroBWT algorithms family" ON)
|
||||
@@ -196,6 +197,10 @@ if (WITH_CN_PICO)
|
||||
add_definitions(/DXMRIG_ALGO_CN_PICO)
|
||||
endif()
|
||||
|
||||
if (WITH_CN_FEMTO)
|
||||
add_definitions(/DXMRIG_ALGO_CN_FEMTO)
|
||||
endif()
|
||||
|
||||
if (WITH_EMBEDDED_CONFIG)
|
||||
add_definitions(/DXMRIG_FEATURE_EMBEDDED_CONFIG)
|
||||
endif()
|
||||
|
||||
@@ -42,13 +42,13 @@ if (WITH_RANDOMX)
|
||||
src/crypto/rx/RxVm.cpp
|
||||
)
|
||||
|
||||
if (CMAKE_C_COMPILER_ID MATCHES MSVC)
|
||||
if (WITH_ASM AND CMAKE_C_COMPILER_ID MATCHES MSVC)
|
||||
enable_language(ASM_MASM)
|
||||
list(APPEND SOURCES_CRYPTO
|
||||
src/crypto/randomx/jit_compiler_x86_static.asm
|
||||
src/crypto/randomx/jit_compiler_x86.cpp
|
||||
)
|
||||
elseif (NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
elseif (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
list(APPEND SOURCES_CRYPTO
|
||||
src/crypto/randomx/jit_compiler_x86_static.S
|
||||
src/crypto/randomx/jit_compiler_x86.cpp
|
||||
|
||||
73
src/3rdparty/llhttp/api.c
vendored
73
src/3rdparty/llhttp/api.c
vendored
@@ -24,6 +24,70 @@ void llhttp_init(llhttp_t* parser, llhttp_type_t type,
|
||||
}
|
||||
|
||||
|
||||
#if defined(__wasm__)
|
||||
|
||||
extern int wasm_on_message_begin(llhttp_t * p);
|
||||
extern int wasm_on_url(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_status(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_header_field(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_header_value(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_headers_complete(llhttp_t * p);
|
||||
extern int wasm_on_body(llhttp_t* p, const char* at, size_t length);
|
||||
extern int wasm_on_message_complete(llhttp_t * p);
|
||||
|
||||
const llhttp_settings_t wasm_settings = {
|
||||
wasm_on_message_begin,
|
||||
wasm_on_url,
|
||||
wasm_on_status,
|
||||
wasm_on_header_field,
|
||||
wasm_on_header_value,
|
||||
wasm_on_headers_complete,
|
||||
wasm_on_body,
|
||||
wasm_on_message_complete,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
llhttp_t* llhttp_alloc(llhttp_type_t type) {
|
||||
llhttp_t* parser = malloc(sizeof(llhttp_t));
|
||||
llhttp_init(parser, type, &wasm_settings);
|
||||
return parser;
|
||||
}
|
||||
|
||||
void llhttp_free(llhttp_t* parser) {
|
||||
free(parser);
|
||||
}
|
||||
|
||||
/* Some getters required to get stuff from the parser */
|
||||
|
||||
uint8_t llhttp_get_type(llhttp_t* parser) {
|
||||
return parser->type;
|
||||
}
|
||||
|
||||
uint8_t llhttp_get_http_major(llhttp_t* parser) {
|
||||
return parser->http_major;
|
||||
}
|
||||
|
||||
uint8_t llhttp_get_http_minor(llhttp_t* parser) {
|
||||
return parser->http_minor;
|
||||
}
|
||||
|
||||
uint8_t llhttp_get_method(llhttp_t* parser) {
|
||||
return parser->method;
|
||||
}
|
||||
|
||||
int llhttp_get_status_code(llhttp_t* parser) {
|
||||
return parser->status_code;
|
||||
}
|
||||
|
||||
uint8_t llhttp_get_upgrade(llhttp_t* parser) {
|
||||
return parser->upgrade;
|
||||
}
|
||||
|
||||
#endif // defined(__wasm__)
|
||||
|
||||
|
||||
void llhttp_reset(llhttp_t* parser) {
|
||||
llhttp_type_t type = parser->type;
|
||||
const llhttp_settings_t* settings = parser->settings;
|
||||
@@ -150,6 +214,7 @@ void llhttp_set_lenient_headers(llhttp_t* parser, int enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled) {
|
||||
if (enabled) {
|
||||
parser->lenient_flags |= LENIENT_CHUNKED_LENGTH;
|
||||
@@ -159,6 +224,14 @@ void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled) {
|
||||
}
|
||||
|
||||
|
||||
void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled) {
|
||||
if (enabled) {
|
||||
parser->lenient_flags |= LENIENT_KEEP_ALIVE;
|
||||
} else {
|
||||
parser->lenient_flags &= ~LENIENT_KEEP_ALIVE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Callbacks */
|
||||
|
||||
|
||||
|
||||
66
src/3rdparty/llhttp/api.h
vendored
66
src/3rdparty/llhttp/api.h
vendored
@@ -5,6 +5,12 @@ extern "C" {
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__wasm__)
|
||||
#define LLHTTP_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LLHTTP_EXPORT
|
||||
#endif
|
||||
|
||||
typedef llhttp__internal_t llhttp_t;
|
||||
typedef struct llhttp_settings_s llhttp_settings_t;
|
||||
|
||||
@@ -55,15 +61,46 @@ struct llhttp_settings_s {
|
||||
* the `parser` here. In practice, `settings` has to be either a static
|
||||
* variable or be allocated with `malloc`, `new`, etc.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_init(llhttp_t* parser, llhttp_type_t type,
|
||||
const llhttp_settings_t* settings);
|
||||
|
||||
#if defined(__wasm__)
|
||||
|
||||
LLHTTP_EXPORT
|
||||
llhttp_t* llhttp_alloc(llhttp_type_t type);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_free(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_type(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_http_major(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_http_minor(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_method(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_get_status_code(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_upgrade(llhttp_t* parser);
|
||||
|
||||
#endif // defined(__wasm__)
|
||||
|
||||
/* Reset an already initialized parser back to the start state, preserving the
|
||||
* existing parser type, callback settings, user data, and lenient flags.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_reset(llhttp_t* parser);
|
||||
|
||||
/* Initialize the settings object */
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_settings_init(llhttp_settings_t* settings);
|
||||
|
||||
/* Parse full or partial request/response, invoking user callbacks along the
|
||||
@@ -82,6 +119,7 @@ void llhttp_settings_init(llhttp_settings_t* settings);
|
||||
* to return the same error upon each successive call up until `llhttp_init()`
|
||||
* is called.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len);
|
||||
|
||||
/* This method should be called when the other side has no further bytes to
|
||||
@@ -92,16 +130,19 @@ llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len);
|
||||
* connection. This method will invoke `on_message_complete()` callback if the
|
||||
* request was terminated safely. Otherwise a error code would be returned.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_finish(llhttp_t* parser);
|
||||
|
||||
/* Returns `1` if the incoming message is parsed until the last byte, and has
|
||||
* to be completed by calling `llhttp_finish()` on EOF
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_message_needs_eof(const llhttp_t* parser);
|
||||
|
||||
/* Returns `1` if there might be any other messages following the last that was
|
||||
* successfully parsed.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_should_keep_alive(const llhttp_t* parser);
|
||||
|
||||
/* Make further calls of `llhttp_execute()` return `HPE_PAUSED` and set
|
||||
@@ -110,6 +151,7 @@ int llhttp_should_keep_alive(const llhttp_t* parser);
|
||||
* Important: do not call this from user callbacks! User callbacks must return
|
||||
* `HPE_PAUSED` if pausing is required.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_pause(llhttp_t* parser);
|
||||
|
||||
/* Might be called to resume the execution after the pause in user's callback.
|
||||
@@ -117,6 +159,7 @@ void llhttp_pause(llhttp_t* parser);
|
||||
*
|
||||
* Call this only if `llhttp_execute()` returns `HPE_PAUSED`.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_resume(llhttp_t* parser);
|
||||
|
||||
/* Might be called to resume the execution after the pause in user's callback.
|
||||
@@ -124,9 +167,11 @@ void llhttp_resume(llhttp_t* parser);
|
||||
*
|
||||
* Call this only if `llhttp_execute()` returns `HPE_PAUSED_UPGRADE`
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_resume_after_upgrade(llhttp_t* parser);
|
||||
|
||||
/* Returns the latest return error */
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_get_errno(const llhttp_t* parser);
|
||||
|
||||
/* Returns the verbal explanation of the latest returned error.
|
||||
@@ -134,6 +179,7 @@ llhttp_errno_t llhttp_get_errno(const llhttp_t* parser);
|
||||
* Note: User callback should set error reason when returning the error. See
|
||||
* `llhttp_set_error_reason()` for details.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_get_error_reason(const llhttp_t* parser);
|
||||
|
||||
/* Assign verbal description to the returned error. Must be called in user
|
||||
@@ -141,6 +187,7 @@ const char* llhttp_get_error_reason(const llhttp_t* parser);
|
||||
*
|
||||
* Note: `HPE_USER` error code might be useful in user callbacks.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_error_reason(llhttp_t* parser, const char* reason);
|
||||
|
||||
/* Returns the pointer to the last parsed byte before the returned error. The
|
||||
@@ -148,12 +195,15 @@ void llhttp_set_error_reason(llhttp_t* parser, const char* reason);
|
||||
*
|
||||
* Note: this method might be useful for counting the number of parsed bytes.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_get_error_pos(const llhttp_t* parser);
|
||||
|
||||
/* Returns textual name of error code */
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_errno_name(llhttp_errno_t err);
|
||||
|
||||
/* Returns textual name of HTTP method */
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_method_name(llhttp_method_t method);
|
||||
|
||||
|
||||
@@ -166,6 +216,7 @@ const char* llhttp_method_name(llhttp_method_t method);
|
||||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
|
||||
|
||||
|
||||
@@ -179,8 +230,23 @@ void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
|
||||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled);
|
||||
|
||||
|
||||
/* Enables/disables lenient handling of `Connection: close` and HTTP/1.0
|
||||
* requests responses.
|
||||
*
|
||||
* Normally `llhttp` would error on (in strict mode) or discard (in loose mode)
|
||||
* the HTTP request/response after the request/response with `Connection: close`
|
||||
* and `Content-Length`. This is important to prevent cache poisoning attacks,
|
||||
* but might interact badly with outdated and insecure clients. With this flag
|
||||
* the extra request/response will be parsed normally.
|
||||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
103
src/3rdparty/llhttp/llhttp.c
vendored
103
src/3rdparty/llhttp/llhttp.c
vendored
@@ -627,6 +627,13 @@ int llhttp__internal__c_update_finish_1(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
return (state->lenient_flags & 4) == 4;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_flags_1(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
@@ -634,7 +641,7 @@ int llhttp__internal__c_test_flags_1(
|
||||
return (state->flags & 544) == 544;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags(
|
||||
int llhttp__internal__c_test_lenient_flags_1(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
@@ -802,7 +809,7 @@ int llhttp__internal__c_update_header_state_2(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags_1(
|
||||
int llhttp__internal__c_test_lenient_flags_2(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
@@ -1661,7 +1668,7 @@ static llparse_state_t llhttp__internal__run(
|
||||
goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_2;
|
||||
}
|
||||
default: {
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_1;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_2;
|
||||
}
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
@@ -5733,10 +5740,20 @@ static llparse_state_t llhttp__internal__run(
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags: {
|
||||
switch (llhttp__internal__c_test_lenient_flags(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_2;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_closed;
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_update_finish_1: {
|
||||
switch (llhttp__internal__c_update_finish_1(state, p, endp)) {
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_closed;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags;
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
@@ -6098,8 +6115,8 @@ static llparse_state_t llhttp__internal__run(
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags: {
|
||||
switch (llhttp__internal__c_test_lenient_flags(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_1: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_1(state, p, endp)) {
|
||||
case 0:
|
||||
goto s_n_llhttp__internal__n_error_15;
|
||||
default:
|
||||
@@ -6111,7 +6128,7 @@ static llparse_state_t llhttp__internal__run(
|
||||
s_n_llhttp__internal__n_invoke_test_flags_1: {
|
||||
switch (llhttp__internal__c_test_flags_1(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_1;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_invoke_llhttp__before_headers_complete;
|
||||
}
|
||||
@@ -6365,8 +6382,8 @@ static llparse_state_t llhttp__internal__run(
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_1: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_1(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_2: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_2(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_header_value_lenient;
|
||||
default:
|
||||
@@ -6727,7 +6744,7 @@ static llparse_state_t llhttp__internal__run(
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_error_29: {
|
||||
state->error = 0x16;
|
||||
state->error = 0x17;
|
||||
state->reason = "Pause on PRI/Upgrade";
|
||||
state->error_pos = (const char*) p;
|
||||
state->_current = (void*) (intptr_t) s_error;
|
||||
@@ -7906,6 +7923,7 @@ reset:
|
||||
|
||||
enum llparse_state_e {
|
||||
s_error,
|
||||
s_n_llhttp__internal__n_closed,
|
||||
s_n_llhttp__internal__n_invoke_llhttp__after_message_complete,
|
||||
s_n_llhttp__internal__n_pause_1,
|
||||
s_n_llhttp__internal__n_invoke_is_equal_upgrade,
|
||||
@@ -8199,6 +8217,13 @@ int llhttp__internal__c_update_finish_1(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
return (state->lenient_flags & 4) == 4;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_flags_1(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
@@ -8206,7 +8231,7 @@ int llhttp__internal__c_test_flags_1(
|
||||
return (state->flags & 544) == 544;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags(
|
||||
int llhttp__internal__c_test_lenient_flags_1(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
@@ -8278,7 +8303,7 @@ int llhttp__internal__c_or_flags(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_update_finish_2(
|
||||
int llhttp__internal__c_update_finish_3(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
@@ -8374,7 +8399,7 @@ int llhttp__internal__c_update_header_state_2(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int llhttp__internal__c_test_lenient_flags_1(
|
||||
int llhttp__internal__c_test_lenient_flags_2(
|
||||
llhttp__internal_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp) {
|
||||
@@ -8574,9 +8599,21 @@ static llparse_state_t llhttp__internal__run(
|
||||
const unsigned char* endp) {
|
||||
int match;
|
||||
switch ((llparse_state_t) (intptr_t) state->_current) {
|
||||
case s_n_llhttp__internal__n_closed:
|
||||
s_n_llhttp__internal__n_closed: {
|
||||
if (p == endp) {
|
||||
return s_n_llhttp__internal__n_closed;
|
||||
}
|
||||
p++;
|
||||
goto s_n_llhttp__internal__n_closed;
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
case s_n_llhttp__internal__n_invoke_llhttp__after_message_complete:
|
||||
s_n_llhttp__internal__n_invoke_llhttp__after_message_complete: {
|
||||
switch (llhttp__after_message_complete(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_2;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_1;
|
||||
}
|
||||
@@ -9045,7 +9082,7 @@ static llparse_state_t llhttp__internal__run(
|
||||
case 3:
|
||||
goto s_n_llhttp__internal__n_span_start_llhttp__on_body_1;
|
||||
case 4:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_2;
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_3;
|
||||
case 5:
|
||||
goto s_n_llhttp__internal__n_error_10;
|
||||
default:
|
||||
@@ -9184,7 +9221,7 @@ static llparse_state_t llhttp__internal__run(
|
||||
goto s_n_llhttp__internal__n_span_end_llhttp__on_header_value_2;
|
||||
}
|
||||
default: {
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_1;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_2;
|
||||
}
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
@@ -13077,7 +13114,7 @@ static llparse_state_t llhttp__internal__run(
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_update_finish_1: {
|
||||
s_n_llhttp__internal__n_invoke_update_finish_2: {
|
||||
switch (llhttp__internal__c_update_finish_1(state, p, endp)) {
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_start;
|
||||
@@ -13085,6 +13122,24 @@ static llparse_state_t llhttp__internal__run(
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags: {
|
||||
switch (llhttp__internal__c_test_lenient_flags(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_update_finish_2;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_closed;
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_update_finish_1: {
|
||||
switch (llhttp__internal__c_update_finish_1(state, p, endp)) {
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags;
|
||||
}
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_pause_5: {
|
||||
state->error = 0x15;
|
||||
state->reason = "on_message_complete pause";
|
||||
@@ -13311,8 +13366,8 @@ static llparse_state_t llhttp__internal__run(
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_update_finish_2: {
|
||||
switch (llhttp__internal__c_update_finish_2(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_update_finish_3: {
|
||||
switch (llhttp__internal__c_update_finish_3(state, p, endp)) {
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_span_start_llhttp__on_body_2;
|
||||
}
|
||||
@@ -13424,8 +13479,8 @@ static llparse_state_t llhttp__internal__run(
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags: {
|
||||
switch (llhttp__internal__c_test_lenient_flags(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_1: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_1(state, p, endp)) {
|
||||
case 0:
|
||||
goto s_n_llhttp__internal__n_error_11;
|
||||
default:
|
||||
@@ -13437,7 +13492,7 @@ static llparse_state_t llhttp__internal__run(
|
||||
s_n_llhttp__internal__n_invoke_test_flags_1: {
|
||||
switch (llhttp__internal__c_test_flags_1(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags;
|
||||
goto s_n_llhttp__internal__n_invoke_test_lenient_flags_1;
|
||||
default:
|
||||
goto s_n_llhttp__internal__n_invoke_llhttp__before_headers_complete;
|
||||
}
|
||||
@@ -13673,8 +13728,8 @@ static llparse_state_t llhttp__internal__run(
|
||||
/* UNREACHABLE */;
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_1: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_1(state, p, endp)) {
|
||||
s_n_llhttp__internal__n_invoke_test_lenient_flags_2: {
|
||||
switch (llhttp__internal__c_test_lenient_flags_2(state, p, endp)) {
|
||||
case 1:
|
||||
goto s_n_llhttp__internal__n_header_value_lenient;
|
||||
default:
|
||||
@@ -14035,7 +14090,7 @@ static llparse_state_t llhttp__internal__run(
|
||||
abort();
|
||||
}
|
||||
s_n_llhttp__internal__n_error_23: {
|
||||
state->error = 0x16;
|
||||
state->error = 0x17;
|
||||
state->reason = "Pause on PRI/Upgrade";
|
||||
state->error_pos = (const char*) p;
|
||||
state->_current = (void*) (intptr_t) s_error;
|
||||
|
||||
79
src/3rdparty/llhttp/llhttp.h
vendored
79
src/3rdparty/llhttp/llhttp.h
vendored
@@ -1,8 +1,8 @@
|
||||
#ifndef INCLUDE_LLHTTP_H_
|
||||
#define INCLUDE_LLHTTP_H_
|
||||
|
||||
#define LLHTTP_VERSION_MAJOR 4
|
||||
#define LLHTTP_VERSION_MINOR 0
|
||||
#define LLHTTP_VERSION_MAJOR 5
|
||||
#define LLHTTP_VERSION_MINOR 1
|
||||
#define LLHTTP_VERSION_PATCH 0
|
||||
|
||||
#ifndef LLHTTP_STRICT_MODE
|
||||
@@ -79,7 +79,8 @@ enum llhttp_errno {
|
||||
HPE_CB_CHUNK_COMPLETE = 20,
|
||||
HPE_PAUSED = 21,
|
||||
HPE_PAUSED_UPGRADE = 22,
|
||||
HPE_USER = 23
|
||||
HPE_PAUSED_H2_UPGRADE = 23,
|
||||
HPE_USER = 24
|
||||
};
|
||||
typedef enum llhttp_errno llhttp_errno_t;
|
||||
|
||||
@@ -98,7 +99,8 @@ typedef enum llhttp_flags llhttp_flags_t;
|
||||
|
||||
enum llhttp_lenient_flags {
|
||||
LENIENT_HEADERS = 0x1,
|
||||
LENIENT_CHUNKED_LENGTH = 0x2
|
||||
LENIENT_CHUNKED_LENGTH = 0x2,
|
||||
LENIENT_KEEP_ALIVE = 0x4
|
||||
};
|
||||
typedef enum llhttp_lenient_flags llhttp_lenient_flags_t;
|
||||
|
||||
@@ -190,7 +192,8 @@ typedef enum llhttp_method llhttp_method_t;
|
||||
XX(20, CB_CHUNK_COMPLETE, CB_CHUNK_COMPLETE) \
|
||||
XX(21, PAUSED, PAUSED) \
|
||||
XX(22, PAUSED_UPGRADE, PAUSED_UPGRADE) \
|
||||
XX(23, USER, USER) \
|
||||
XX(23, PAUSED_H2_UPGRADE, PAUSED_H2_UPGRADE) \
|
||||
XX(24, USER, USER) \
|
||||
|
||||
|
||||
#define HTTP_METHOD_MAP(XX) \
|
||||
@@ -255,6 +258,12 @@ extern "C" {
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__wasm__)
|
||||
#define LLHTTP_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LLHTTP_EXPORT
|
||||
#endif
|
||||
|
||||
typedef llhttp__internal_t llhttp_t;
|
||||
typedef struct llhttp_settings_s llhttp_settings_t;
|
||||
|
||||
@@ -305,15 +314,46 @@ struct llhttp_settings_s {
|
||||
* the `parser` here. In practice, `settings` has to be either a static
|
||||
* variable or be allocated with `malloc`, `new`, etc.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_init(llhttp_t* parser, llhttp_type_t type,
|
||||
const llhttp_settings_t* settings);
|
||||
|
||||
#if defined(__wasm__)
|
||||
|
||||
LLHTTP_EXPORT
|
||||
llhttp_t* llhttp_alloc(llhttp_type_t type);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_free(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_type(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_http_major(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_http_minor(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_method(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_get_status_code(llhttp_t* parser);
|
||||
|
||||
LLHTTP_EXPORT
|
||||
uint8_t llhttp_get_upgrade(llhttp_t* parser);
|
||||
|
||||
#endif // defined(__wasm__)
|
||||
|
||||
/* Reset an already initialized parser back to the start state, preserving the
|
||||
* existing parser type, callback settings, user data, and lenient flags.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_reset(llhttp_t* parser);
|
||||
|
||||
/* Initialize the settings object */
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_settings_init(llhttp_settings_t* settings);
|
||||
|
||||
/* Parse full or partial request/response, invoking user callbacks along the
|
||||
@@ -332,6 +372,7 @@ void llhttp_settings_init(llhttp_settings_t* settings);
|
||||
* to return the same error upon each successive call up until `llhttp_init()`
|
||||
* is called.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len);
|
||||
|
||||
/* This method should be called when the other side has no further bytes to
|
||||
@@ -342,16 +383,19 @@ llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len);
|
||||
* connection. This method will invoke `on_message_complete()` callback if the
|
||||
* request was terminated safely. Otherwise a error code would be returned.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_finish(llhttp_t* parser);
|
||||
|
||||
/* Returns `1` if the incoming message is parsed until the last byte, and has
|
||||
* to be completed by calling `llhttp_finish()` on EOF
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_message_needs_eof(const llhttp_t* parser);
|
||||
|
||||
/* Returns `1` if there might be any other messages following the last that was
|
||||
* successfully parsed.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
int llhttp_should_keep_alive(const llhttp_t* parser);
|
||||
|
||||
/* Make further calls of `llhttp_execute()` return `HPE_PAUSED` and set
|
||||
@@ -360,6 +404,7 @@ int llhttp_should_keep_alive(const llhttp_t* parser);
|
||||
* Important: do not call this from user callbacks! User callbacks must return
|
||||
* `HPE_PAUSED` if pausing is required.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_pause(llhttp_t* parser);
|
||||
|
||||
/* Might be called to resume the execution after the pause in user's callback.
|
||||
@@ -367,6 +412,7 @@ void llhttp_pause(llhttp_t* parser);
|
||||
*
|
||||
* Call this only if `llhttp_execute()` returns `HPE_PAUSED`.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_resume(llhttp_t* parser);
|
||||
|
||||
/* Might be called to resume the execution after the pause in user's callback.
|
||||
@@ -374,9 +420,11 @@ void llhttp_resume(llhttp_t* parser);
|
||||
*
|
||||
* Call this only if `llhttp_execute()` returns `HPE_PAUSED_UPGRADE`
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_resume_after_upgrade(llhttp_t* parser);
|
||||
|
||||
/* Returns the latest return error */
|
||||
LLHTTP_EXPORT
|
||||
llhttp_errno_t llhttp_get_errno(const llhttp_t* parser);
|
||||
|
||||
/* Returns the verbal explanation of the latest returned error.
|
||||
@@ -384,6 +432,7 @@ llhttp_errno_t llhttp_get_errno(const llhttp_t* parser);
|
||||
* Note: User callback should set error reason when returning the error. See
|
||||
* `llhttp_set_error_reason()` for details.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_get_error_reason(const llhttp_t* parser);
|
||||
|
||||
/* Assign verbal description to the returned error. Must be called in user
|
||||
@@ -391,6 +440,7 @@ const char* llhttp_get_error_reason(const llhttp_t* parser);
|
||||
*
|
||||
* Note: `HPE_USER` error code might be useful in user callbacks.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_error_reason(llhttp_t* parser, const char* reason);
|
||||
|
||||
/* Returns the pointer to the last parsed byte before the returned error. The
|
||||
@@ -398,12 +448,15 @@ void llhttp_set_error_reason(llhttp_t* parser, const char* reason);
|
||||
*
|
||||
* Note: this method might be useful for counting the number of parsed bytes.
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_get_error_pos(const llhttp_t* parser);
|
||||
|
||||
/* Returns textual name of error code */
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_errno_name(llhttp_errno_t err);
|
||||
|
||||
/* Returns textual name of HTTP method */
|
||||
LLHTTP_EXPORT
|
||||
const char* llhttp_method_name(llhttp_method_t method);
|
||||
|
||||
|
||||
@@ -416,6 +469,7 @@ const char* llhttp_method_name(llhttp_method_t method);
|
||||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
|
||||
|
||||
|
||||
@@ -429,8 +483,23 @@ void llhttp_set_lenient_headers(llhttp_t* parser, int enabled);
|
||||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
LLHTTP_EXPORT
|
||||
void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled);
|
||||
|
||||
|
||||
/* Enables/disables lenient handling of `Connection: close` and HTTP/1.0
|
||||
* requests responses.
|
||||
*
|
||||
* Normally `llhttp` would error on (in strict mode) or discard (in loose mode)
|
||||
* the HTTP request/response after the request/response with `Connection: close`
|
||||
* and `Content-Length`. This is important to prevent cache poisoning attacks,
|
||||
* but might interact badly with outdated and insecure clients. With this flag
|
||||
* the extra request/response will be parsed normally.
|
||||
*
|
||||
* **(USE AT YOUR OWN RISK)**
|
||||
*/
|
||||
void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
#define XMRIG_WORKERS_H
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
#include "backend/common/Thread.h"
|
||||
#include "backend/cpu/CpuLaunchData.h"
|
||||
|
||||
|
||||
@@ -334,13 +334,11 @@ void xmrig::CpuBackend::printHashrate(bool details)
|
||||
i++;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
Log::print(WHITE_BOLD_S "| - | - | %7s | %7s | %7s |",
|
||||
Hashrate::format(hashrate()->calc(Hashrate::ShortInterval), num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(Hashrate::MediumInterval), num + 8, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3)
|
||||
);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -197,6 +197,7 @@ void xmrig::CpuConfig::generate()
|
||||
count += xmrig::generate<Algorithm::CN_LITE>(m_threads, m_limit);
|
||||
count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, m_limit);
|
||||
count += xmrig::generate<Algorithm::CN_PICO>(m_threads, m_limit);
|
||||
count += xmrig::generate<Algorithm::CN_FEMTO>(m_threads, m_limit);
|
||||
count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, m_limit);
|
||||
count += xmrig::generate<Algorithm::ARGON2>(m_threads, m_limit);
|
||||
count += xmrig::generate<Algorithm::ASTROBWT>(m_threads, m_limit);
|
||||
|
||||
@@ -100,6 +100,15 @@ size_t inline generate<Algorithm::CN_PICO>(Threads<CpuThreads> &threads, uint32_
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_FEMTO
|
||||
template<>
|
||||
size_t inline generate<Algorithm::CN_FEMTO>(Threads<CpuThreads>& threads, uint32_t limit)
|
||||
{
|
||||
return generate("cn/upx2", threads, Algorithm::CN_UPX2, limit);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
template<>
|
||||
size_t inline generate<Algorithm::RANDOM_X>(Threads<CpuThreads> &threads, uint32_t limit)
|
||||
|
||||
@@ -193,6 +193,12 @@ bool xmrig::CpuWorker<N>::selfTest()
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
if (m_algorithm.family() == Algorithm::CN_FEMTO) {
|
||||
return verify(Algorithm::CN_UPX2, test_output_femto_upx2);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
if (m_algorithm.family() == Algorithm::ARGON2) {
|
||||
return verify(Algorithm::AR2_CHUKWA, argon2_chukwa_test_out) &&
|
||||
|
||||
@@ -309,26 +309,34 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3
|
||||
return 1;
|
||||
}
|
||||
|
||||
Algorithm::Family f = algorithm.family();
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
if (algorithm.family() == Algorithm::CN_LITE) {
|
||||
if (f == Algorithm::CN_LITE) {
|
||||
return CpuThreads(count, 1);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
if (algorithm.family() == Algorithm::CN_PICO) {
|
||||
if (f == Algorithm::CN_PICO) {
|
||||
return CpuThreads(count, 2);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
if (f == Algorithm::CN_FEMTO) {
|
||||
return CpuThreads(count, 2);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||
if (algorithm.family() == Algorithm::CN_HEAVY) {
|
||||
if (f == Algorithm::CN_HEAVY) {
|
||||
return CpuThreads(std::max<size_t>(count / 4, 1), 1);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (algorithm.family() == Algorithm::RANDOM_X) {
|
||||
if (f == Algorithm::RANDOM_X) {
|
||||
if (algorithm == Algorithm::RX_WOW) {
|
||||
return count;
|
||||
}
|
||||
@@ -338,13 +346,13 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
if (algorithm.family() == Algorithm::ARGON2) {
|
||||
if (f == Algorithm::ARGON2) {
|
||||
return count;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
if (algorithm.family() == Algorithm::ASTROBWT) {
|
||||
if (f == Algorithm::ASTROBWT) {
|
||||
CpuThreads threads;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
threads.add(i, 0);
|
||||
|
||||
@@ -336,11 +336,10 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
|
||||
|
||||
size_t cacheHashes = ((L3 + extra) + (scratchpad / 2)) / scratchpad;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
if (intensity && algorithm == Algorithm::CN_PICO_0 && (cacheHashes / PUs) >= 2) {
|
||||
Algorithm::Family family = algorithm.family();
|
||||
if (intensity && ((family == Algorithm::CN_PICO) || (family == Algorithm::CN_FEMTO)) && (cacheHashes / PUs) >= 2) {
|
||||
intensity = 2;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (extra == 0 && algorithm.l2() > 0) {
|
||||
|
||||
@@ -179,6 +179,7 @@ void xmrig::CudaConfig::generate()
|
||||
count += xmrig::generate<Algorithm::CN_LITE>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::CN_PICO>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::CN_FEMTO>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::ASTROBWT>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::KAWPOW>(m_threads, devices);
|
||||
|
||||
@@ -102,6 +102,15 @@ size_t inline generate<Algorithm::CN_PICO>(Threads<CudaThreads> &threads, const
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_FEMTO
|
||||
template<>
|
||||
size_t inline generate<Algorithm::CN_FEMTO>(Threads<CudaThreads>& threads, const std::vector<CudaDevice>& devices)
|
||||
{
|
||||
return generate("cn/upx2", threads, Algorithm::CN_UPX2, devices);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
template<>
|
||||
size_t inline generate<Algorithm::RANDOM_X>(Threads<CudaThreads> &threads, const std::vector<CudaDevice> &devices)
|
||||
|
||||
@@ -219,6 +219,7 @@ void xmrig::OclConfig::generate()
|
||||
count += xmrig::generate<Algorithm::CN_LITE>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::CN_PICO>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::CN_FEMTO>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::ASTROBWT>(m_threads, devices);
|
||||
count += xmrig::generate<Algorithm::KAWPOW>(m_threads, devices);
|
||||
|
||||
@@ -101,6 +101,15 @@ size_t inline generate<Algorithm::CN_PICO>(Threads<OclThreads> &threads, const s
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_FEMTO
|
||||
template<>
|
||||
size_t inline generate<Algorithm::CN_FEMTO>(Threads<OclThreads>& threads, const std::vector<OclDevice>& devices)
|
||||
{
|
||||
return generate("cn/upx2", threads, Algorithm::CN_UPX2, devices);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
template<>
|
||||
size_t inline generate<Algorithm::RANDOM_X>(Threads<OclThreads> &threads, const std::vector<OclDevice> &devices)
|
||||
|
||||
@@ -17,16 +17,17 @@
|
||||
#define ALGO_CN_PICO_0 16
|
||||
#define ALGO_CN_PICO_TLO 17
|
||||
#define ALGO_CN_CCX 18
|
||||
#define ALGO_RX_0 19
|
||||
#define ALGO_RX_WOW 20
|
||||
#define ALGO_RX_ARQMA 21
|
||||
#define ALGO_RX_SFX 22
|
||||
#define ALGO_RX_KEVA 23
|
||||
#define ALGO_AR2_CHUKWA 24
|
||||
#define ALGO_AR2_CHUKWA_V2 25
|
||||
#define ALGO_AR2_WRKZ 26
|
||||
#define ALGO_ASTROBWT_DERO 27
|
||||
#define ALGO_KAWPOW_RVN 28
|
||||
#define ALGO_CN_UPX2 19
|
||||
#define ALGO_RX_0 20
|
||||
#define ALGO_RX_WOW 21
|
||||
#define ALGO_RX_ARQMA 22
|
||||
#define ALGO_RX_SFX 23
|
||||
#define ALGO_RX_KEVA 24
|
||||
#define ALGO_AR2_CHUKWA 25
|
||||
#define ALGO_AR2_CHUKWA_V2 26
|
||||
#define ALGO_AR2_WRKZ 27
|
||||
#define ALGO_ASTROBWT_DERO 28
|
||||
#define ALGO_KAWPOW_RVN 29
|
||||
|
||||
#define FAMILY_UNKNOWN 0
|
||||
#define FAMILY_CN 1
|
||||
|
||||
@@ -514,7 +514,7 @@ __kernel void cn1(__global ulong *input, __global uint4 *Scratchpad, __global ul
|
||||
c = AES_Round(AES0, AES1, AES2, AES3, c, ((uint4 *)a)[0]);
|
||||
|
||||
{
|
||||
# if (ALGO == ALGO_CN_RWZ)
|
||||
# if ((ALGO == ALGO_CN_RWZ) || (ALGO == ALGO_CN_UPX2))
|
||||
const ulong2 chunk1 = as_ulong2(SCRATCHPAD_CHUNK(3));
|
||||
const ulong2 chunk2 = as_ulong2(SCRATCHPAD_CHUNK(2));
|
||||
const ulong2 chunk3 = as_ulong2(SCRATCHPAD_CHUNK(1));
|
||||
@@ -561,7 +561,7 @@ __kernel void cn1(__global ulong *input, __global uint4 *Scratchpad, __global ul
|
||||
t ^= chunk2;
|
||||
const ulong2 chunk3 = as_ulong2(SCRATCHPAD_CHUNK(3));
|
||||
|
||||
# if (ALGO == ALGO_CN_RWZ)
|
||||
# if ((ALGO == ALGO_CN_RWZ) || (ALGO == ALGO_CN_UPX2))
|
||||
SCRATCHPAD_CHUNK(1) = as_uint4(chunk1 + bx1);
|
||||
SCRATCHPAD_CHUNK(2) = as_uint4(chunk3 + bx0);
|
||||
SCRATCHPAD_CHUNK(3) = as_uint4(chunk2 + ((ulong2 *)a)[0]);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -88,7 +88,8 @@ static inline uint32_t getIntensity(const OclDevice &device, const Algorithm &al
|
||||
|
||||
static inline uint32_t getWorksize(const Algorithm &algorithm)
|
||||
{
|
||||
if (algorithm.family() == Algorithm::CN_PICO) {
|
||||
Algorithm::Family f = algorithm.family();
|
||||
if (f == Algorithm::CN_PICO || f == Algorithm::CN_FEMTO) {
|
||||
return 64;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,12 @@
|
||||
xmrig::OclCnRunner::OclCnRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
||||
{
|
||||
uint32_t stridedIndex = data.thread.stridedIndex();
|
||||
Algorithm::Family f = m_algorithm.family();
|
||||
|
||||
if (data.device.vendorId() == OCL_VENDOR_NVIDIA) {
|
||||
stridedIndex = 0;
|
||||
}
|
||||
else if (stridedIndex == 1 && (m_algorithm.family() == Algorithm::CN_PICO || (m_algorithm.family() == Algorithm::CN && CnAlgo<>::base(m_algorithm) == Algorithm::CN_2))) {
|
||||
else if (stridedIndex == 1 && (f == Algorithm::CN_PICO || f == Algorithm::CN_FEMTO || (f == Algorithm::CN && CnAlgo<>::base(m_algorithm) == Algorithm::CN_2))) {
|
||||
stridedIndex = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "backend/opencl/wrappers/OclDevice.h"
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
@@ -32,6 +32,7 @@ set(HEADERS_BASE
|
||||
src/base/kernel/interfaces/IConfigListener.h
|
||||
src/base/kernel/interfaces/IConfigTransform.h
|
||||
src/base/kernel/interfaces/IConsoleListener.h
|
||||
src/base/kernel/interfaces/IDnsBackend.h
|
||||
src/base/kernel/interfaces/IDnsListener.h
|
||||
src/base/kernel/interfaces/ILineListener.h
|
||||
src/base/kernel/interfaces/ILogBackend.h
|
||||
@@ -43,7 +44,11 @@ set(HEADERS_BASE
|
||||
src/base/kernel/Platform.h
|
||||
src/base/kernel/Process.h
|
||||
src/base/net/dns/Dns.h
|
||||
src/base/net/dns/DnsConfig.h
|
||||
src/base/net/dns/DnsRecord.h
|
||||
src/base/net/dns/DnsRecords.h
|
||||
src/base/net/dns/DnsRequest.h
|
||||
src/base/net/dns/DnsUvBackend.h
|
||||
src/base/net/http/Http.h
|
||||
src/base/net/http/HttpListener.h
|
||||
src/base/net/stratum/BaseClient.h
|
||||
@@ -99,7 +104,10 @@ set(SOURCES_BASE
|
||||
src/base/kernel/Platform.cpp
|
||||
src/base/kernel/Process.cpp
|
||||
src/base/net/dns/Dns.cpp
|
||||
src/base/net/dns/DnsConfig.cpp
|
||||
src/base/net/dns/DnsRecord.cpp
|
||||
src/base/net/dns/DnsRecords.cpp
|
||||
src/base/net/dns/DnsUvBackend.cpp
|
||||
src/base/net/http/Http.cpp
|
||||
src/base/net/stratum/BaseClient.cpp
|
||||
src/base/net/stratum/Client.cpp
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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
|
||||
@@ -129,6 +129,11 @@ static AlgoName const algorithm_names[] = {
|
||||
# endif
|
||||
{ "cryptonight/ccx", "cn/ccx", Algorithm::CN_CCX },
|
||||
{ "cryptonight/conceal", "cn/conceal", Algorithm::CN_CCX },
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
{ "cryptonight/upx2", "cn/upx2", Algorithm::CN_UPX2 },
|
||||
{ "cn-extremelite/upx2", nullptr, Algorithm::CN_UPX2 },
|
||||
{ "cryptonight-upx/2", nullptr, Algorithm::CN_UPX2 },
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
@@ -199,6 +204,9 @@ size_t xmrig::Algorithm::l3() const
|
||||
case CN_PICO:
|
||||
return oneMiB / 4;
|
||||
|
||||
case CN_FEMTO:
|
||||
return oneMiB / 8;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -329,6 +337,11 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
||||
return CN_PICO;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
case CN_UPX2:
|
||||
return CN_FEMTO;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
case RX_0:
|
||||
case RX_WOW:
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
CN_PICO_0, // "cn-pico" CryptoNight-Pico
|
||||
CN_PICO_TLO, // "cn-pico/tlo" CryptoNight-Pico (TLO)
|
||||
CN_CCX, // "cn/ccx" Conceal (CCX)
|
||||
CN_UPX2, // "cn/upx2" Uplexa (UPX2)
|
||||
RX_0, // "rx/0" RandomX (reference configuration).
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||
@@ -83,6 +84,7 @@ public:
|
||||
CN_LITE,
|
||||
CN_HEAVY,
|
||||
CN_PICO,
|
||||
CN_FEMTO,
|
||||
RANDOM_X,
|
||||
ARGON2,
|
||||
ASTROBWT,
|
||||
@@ -94,7 +96,7 @@ public:
|
||||
inline Algorithm(Id id) : m_id(id) {}
|
||||
Algorithm(const rapidjson::Value &value);
|
||||
|
||||
inline bool isCN() const { auto f = family(); return f == CN || f == CN_LITE || f == CN_HEAVY || f == CN_PICO; }
|
||||
inline bool isCN() const { auto f = family(); return f == CN || f == CN_LITE || f == CN_HEAVY || f == CN_PICO || f == CN_FEMTO; }
|
||||
inline bool isEqual(const Algorithm &other) const { return m_id == other.m_id; }
|
||||
inline bool isValid() const { return m_id != INVALID && family() != UNKNOWN; }
|
||||
inline const char *name() const { return name(false); }
|
||||
|
||||
@@ -91,7 +91,7 @@ bool xmrig::FileLogWriter::writeLine(const char *data, size_t size)
|
||||
{
|
||||
const uv_buf_t buf[2] = {
|
||||
uv_buf_init(new char[size], size),
|
||||
uv_buf_init(m_endl, sizeof(m_endl) - 1)
|
||||
uv_buf_init(const_cast<char *>(m_endl), sizeof(m_endl) - 1)
|
||||
};
|
||||
|
||||
memcpy(buf[0].base, data, size);
|
||||
|
||||
@@ -42,9 +42,9 @@ public:
|
||||
|
||||
private:
|
||||
# ifdef XMRIG_OS_WIN
|
||||
char m_endl[3] = "\r\n";
|
||||
const char m_endl[3] = {'\r', '\n', 0};
|
||||
# else
|
||||
char m_endl[2] = "\n";
|
||||
const char m_endl[2] = {'\n', 0};
|
||||
# endif
|
||||
|
||||
int m_file = -1;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/kernel/interfaces/IJsonReader.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
@@ -105,6 +106,8 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||
m_http.load(reader.getObject(kHttp));
|
||||
m_pools.load(reader);
|
||||
|
||||
Dns::set(reader.getObject(DnsConfig::kField));
|
||||
|
||||
return m_pools.active() > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "base/kernel/config/BaseConfig.h"
|
||||
#include "base/kernel/interfaces/IConfig.h"
|
||||
#include "base/kernel/Process.h"
|
||||
#include "base/net/dns/DnsConfig.h"
|
||||
#include "base/net/stratum/Pool.h"
|
||||
#include "base/net/stratum/Pools.h"
|
||||
#include "core/config/Config_platform.h"
|
||||
@@ -244,6 +245,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||
case IConfig::HttpPort: /* --http-port */
|
||||
case IConfig::DonateLevelKey: /* --donate-level */
|
||||
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
||||
case IConfig::DnsTtlKey: /* --dns-ttl */
|
||||
return transformUint64(doc, key, static_cast<uint64_t>(strtol(arg, nullptr, 10)));
|
||||
|
||||
case IConfig::BackgroundKey: /* --background */
|
||||
@@ -256,6 +258,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||
case IConfig::DaemonKey: /* --daemon */
|
||||
case IConfig::SubmitToOriginKey: /* --submit-to-origin */
|
||||
case IConfig::VerboseKey: /* --verbose */
|
||||
case IConfig::DnsIPv6Key: /* --dns-ipv6 */
|
||||
return transformBoolean(doc, key, true);
|
||||
|
||||
case IConfig::ColorKey: /* --no-color */
|
||||
@@ -316,6 +319,9 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
|
||||
case IConfig::NoTitleKey: /* --no-title */
|
||||
return set(doc, BaseConfig::kTitle, enable);
|
||||
|
||||
case IConfig::DnsIPv6Key: /* --dns-ipv6 */
|
||||
return set(doc, DnsConfig::kField, DnsConfig::kIPv6, enable);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -344,6 +350,9 @@ void xmrig::BaseTransform::transformUint64(rapidjson::Document &doc, int key, ui
|
||||
case IConfig::PrintTimeKey: /* --print-time */
|
||||
return set(doc, BaseConfig::kPrintTime, arg);
|
||||
|
||||
case IConfig::DnsTtlKey: /* --dns-ttl */
|
||||
return set(doc, DnsConfig::kField, DnsConfig::kTTL, arg);
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
case IConfig::DaemonPollKey: /* --daemon-poll-interval */
|
||||
return add(doc, Pools::kPools, Pool::kDaemonPollInterval, arg);
|
||||
|
||||
@@ -82,6 +82,8 @@ public:
|
||||
HugePageSizeKey = 1050,
|
||||
PauseOnActiveKey = 1051,
|
||||
SubmitToOriginKey = 1052,
|
||||
DnsIPv6Key = 1053,
|
||||
DnsTtlKey = 1054,
|
||||
|
||||
// xmrig common
|
||||
CPUPriorityKey = 1021,
|
||||
|
||||
54
src/base/kernel/interfaces/IDnsBackend.h
Normal file
54
src/base/kernel/interfaces/IDnsBackend.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that 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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_IDNSBACKEND_H
|
||||
#define XMRIG_IDNSBACKEND_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class DnsRecords;
|
||||
class DnsRequest;
|
||||
class IDnsListener;
|
||||
class String;
|
||||
|
||||
|
||||
class IDnsBackend
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(IDnsBackend)
|
||||
|
||||
IDnsBackend() = default;
|
||||
virtual ~IDnsBackend() = default;
|
||||
|
||||
virtual const DnsRecords &records() const = 0;
|
||||
virtual std::shared_ptr<DnsRequest> resolve(const String &host, IDnsListener *listener, uint64_t ttl) = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_IDNSBACKEND_H
|
||||
@@ -1,6 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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
|
||||
@@ -26,7 +26,7 @@
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Dns;
|
||||
class DnsRecords;
|
||||
|
||||
|
||||
class IDnsListener
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
IDnsListener() = default;
|
||||
virtual ~IDnsListener() = default;
|
||||
|
||||
virtual void onResolved(const Dns &dns, int status) = 0;
|
||||
virtual void onResolved(const DnsRecords &records, int status, const char *error) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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
|
||||
@@ -18,136 +18,24 @@
|
||||
|
||||
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/kernel/interfaces/IDnsListener.h"
|
||||
#include "base/net/dns/DnsUvBackend.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
Storage<Dns> Dns::m_storage;
|
||||
static const DnsRecord defaultRecord;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Dns::Dns(IDnsListener *listener) :
|
||||
m_listener(listener)
|
||||
DnsConfig Dns::m_config;
|
||||
std::map<String, std::shared_ptr<IDnsBackend> > Dns::m_backends;
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
std::shared_ptr<xmrig::DnsRequest> xmrig::Dns::resolve(const String &host, IDnsListener *listener, uint64_t ttl)
|
||||
{
|
||||
m_key = m_storage.add(this);
|
||||
if (m_backends.find(host) == m_backends.end()) {
|
||||
m_backends.insert({ host, std::make_shared<DnsUvBackend>() });
|
||||
}
|
||||
|
||||
m_resolver = new uv_getaddrinfo_t;
|
||||
m_resolver->data = m_storage.ptr(m_key);
|
||||
|
||||
m_hints.ai_family = AF_UNSPEC;
|
||||
m_hints.ai_socktype = SOCK_STREAM;
|
||||
m_hints.ai_protocol = IPPROTO_TCP;
|
||||
}
|
||||
|
||||
|
||||
xmrig::Dns::~Dns()
|
||||
{
|
||||
m_storage.release(m_key);
|
||||
|
||||
delete m_resolver;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Dns::resolve(const String &host)
|
||||
{
|
||||
if (m_host != host) {
|
||||
m_host = host;
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
m_status = uv_getaddrinfo(uv_default_loop(), m_resolver, Dns::onResolved, m_host.data(), nullptr, &m_hints);
|
||||
|
||||
return m_status == 0;
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::Dns::error() const
|
||||
{
|
||||
return uv_strerror(m_status);
|
||||
}
|
||||
|
||||
|
||||
const xmrig::DnsRecord &xmrig::Dns::get(DnsRecord::Type prefered) const
|
||||
{
|
||||
if (count() == 0) {
|
||||
return defaultRecord;
|
||||
}
|
||||
|
||||
const size_t ipv4 = m_ipv4.size();
|
||||
const size_t ipv6 = m_ipv6.size();
|
||||
|
||||
if (ipv6 && (prefered == DnsRecord::AAAA || !ipv4)) {
|
||||
return m_ipv6[ipv6 == 1 ? 0 : static_cast<size_t>(rand()) % ipv6];
|
||||
}
|
||||
|
||||
if (ipv4) {
|
||||
return m_ipv4[ipv4 == 1 ? 0 : static_cast<size_t>(rand()) % ipv4];
|
||||
}
|
||||
|
||||
return defaultRecord;
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::Dns::count(DnsRecord::Type type) const
|
||||
{
|
||||
if (type == DnsRecord::A) {
|
||||
return m_ipv4.size();
|
||||
}
|
||||
|
||||
if (type == DnsRecord::AAAA) {
|
||||
return m_ipv6.size();
|
||||
}
|
||||
|
||||
return m_ipv4.size() + m_ipv6.size();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Dns::clear()
|
||||
{
|
||||
m_ipv4.clear();
|
||||
m_ipv6.clear();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Dns::onResolved(int status, addrinfo *res)
|
||||
{
|
||||
m_status = status;
|
||||
|
||||
if (m_status < 0) {
|
||||
return m_listener->onResolved(*this, status);
|
||||
}
|
||||
|
||||
clear();
|
||||
|
||||
addrinfo *ptr = res;
|
||||
while (ptr != nullptr) {
|
||||
if (ptr->ai_family == AF_INET) {
|
||||
m_ipv4.emplace_back(ptr);
|
||||
}
|
||||
|
||||
if (ptr->ai_family == AF_INET6) {
|
||||
m_ipv6.emplace_back(ptr);
|
||||
}
|
||||
|
||||
ptr = ptr->ai_next;
|
||||
}
|
||||
|
||||
if (isEmpty()) {
|
||||
m_status = UV_EAI_NONAME;
|
||||
}
|
||||
|
||||
m_listener->onResolved(*this, m_status);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Dns::onResolved(uv_getaddrinfo_t *req, int status, addrinfo *res)
|
||||
{
|
||||
Dns *dns = m_storage.get(req->data);
|
||||
if (dns) {
|
||||
dns->onResolved(status, res);
|
||||
}
|
||||
|
||||
uv_freeaddrinfo(res);
|
||||
return m_backends.at(host)->resolve(host, listener, ttl == 0 ? m_config.ttl() : ttl);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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
|
||||
@@ -20,55 +20,34 @@
|
||||
#define XMRIG_DNS_H
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/net/dns/DnsRecord.h"
|
||||
#include "base/net/tools/Storage.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "base/net/dns/DnsConfig.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class DnsConfig;
|
||||
class DnsRequest;
|
||||
class IDnsBackend;
|
||||
class IDnsListener;
|
||||
|
||||
|
||||
class Dns
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Dns)
|
||||
inline static const DnsConfig &config() { return m_config; }
|
||||
inline static void set(const DnsConfig &config) { m_config = config; }
|
||||
|
||||
Dns(IDnsListener *listener);
|
||||
~Dns();
|
||||
|
||||
inline bool isEmpty() const { return m_ipv4.empty() && m_ipv6.empty(); }
|
||||
inline const String &host() const { return m_host; }
|
||||
inline int status() const { return m_status; }
|
||||
|
||||
bool resolve(const String &host);
|
||||
const char *error() const;
|
||||
const DnsRecord &get(DnsRecord::Type prefered = DnsRecord::A) const;
|
||||
size_t count(DnsRecord::Type type = DnsRecord::Unknown) const;
|
||||
static std::shared_ptr<DnsRequest> resolve(const String &host, IDnsListener *listener, uint64_t ttl = 0);
|
||||
|
||||
private:
|
||||
void clear();
|
||||
void onResolved(int status, addrinfo *res);
|
||||
|
||||
static void onResolved(uv_getaddrinfo_t *req, int status, addrinfo *res);
|
||||
|
||||
addrinfo m_hints{};
|
||||
IDnsListener *m_listener;
|
||||
int m_status = 0;
|
||||
std::vector<DnsRecord> m_ipv4;
|
||||
std::vector<DnsRecord> m_ipv6;
|
||||
String m_host;
|
||||
uintptr_t m_key;
|
||||
uv_getaddrinfo_t *m_resolver = nullptr;
|
||||
|
||||
static Storage<Dns> m_storage;
|
||||
static DnsConfig m_config;
|
||||
static std::map<String, std::shared_ptr<IDnsBackend> > m_backends;
|
||||
};
|
||||
|
||||
|
||||
|
||||
57
src/base/net/dns/DnsConfig.cpp
Normal file
57
src/base/net/dns/DnsConfig.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that 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 "base/net/dns/DnsConfig.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "base/io/json/Json.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
const char *DnsConfig::kField = "dns";
|
||||
const char *DnsConfig::kIPv6 = "ipv6";
|
||||
const char *DnsConfig::kTTL = "ttl";
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::DnsConfig::DnsConfig(const rapidjson::Value &value)
|
||||
{
|
||||
m_ipv6 = Json::getBool(value, kIPv6, m_ipv6);
|
||||
m_ttl = std::max(Json::getUint(value, kTTL, m_ttl), 1U);
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::DnsConfig::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
auto &allocator = doc.GetAllocator();
|
||||
Value obj(kObjectType);
|
||||
|
||||
obj.AddMember(StringRef(kIPv6), m_ipv6, allocator);
|
||||
obj.AddMember(StringRef(kTTL), m_ttl, allocator);
|
||||
|
||||
return obj;
|
||||
}
|
||||
54
src/base/net/dns/DnsConfig.h
Normal file
54
src/base/net/dns/DnsConfig.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that 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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_DNSCONFIG_H
|
||||
#define XMRIG_DNSCONFIG_H
|
||||
|
||||
|
||||
#include "3rdparty/rapidjson/fwd.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class DnsConfig
|
||||
{
|
||||
public:
|
||||
static const char *kField;
|
||||
static const char *kIPv6;
|
||||
static const char *kTTL;
|
||||
|
||||
DnsConfig() = default;
|
||||
DnsConfig(const rapidjson::Value &object);
|
||||
|
||||
inline bool isIPv6() const { return m_ipv6; }
|
||||
inline uint32_t ttl() const { return m_ttl * 1000U; }
|
||||
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
|
||||
|
||||
private:
|
||||
bool m_ipv6 = false;
|
||||
uint32_t m_ttl = 30U;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_DNSCONFIG_H */
|
||||
@@ -1,6 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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
|
||||
@@ -24,38 +24,34 @@
|
||||
|
||||
|
||||
xmrig::DnsRecord::DnsRecord(const addrinfo *addr) :
|
||||
m_type(addr->ai_family == AF_INET6 ? AAAA : A)
|
||||
m_type(addr->ai_family == AF_INET6 ? AAAA : (addr->ai_family == AF_INET ? A : Unknown))
|
||||
{
|
||||
static_assert(sizeof(m_data) >= sizeof(sockaddr_in6), "Not enough storage for IPv6 address.");
|
||||
|
||||
memcpy(m_data, addr->ai_addr, m_type == AAAA ? sizeof(sockaddr_in6) : sizeof(sockaddr_in));
|
||||
}
|
||||
|
||||
|
||||
const sockaddr *xmrig::DnsRecord::addr(uint16_t port) const
|
||||
{
|
||||
reinterpret_cast<sockaddr_in*>(m_data)->sin_port = htons(port);
|
||||
|
||||
return reinterpret_cast<const sockaddr *>(m_data);
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::DnsRecord::ip() const
|
||||
{
|
||||
char *buf = nullptr;
|
||||
|
||||
if (m_type == AAAA) {
|
||||
buf = new char[45]();
|
||||
uv_ip6_name(reinterpret_cast<sockaddr_in6*>(addr->ai_addr), buf, 45);
|
||||
uv_ip6_name(reinterpret_cast<sockaddr_in6*>(m_data), buf, 45);
|
||||
}
|
||||
else {
|
||||
buf = new char[16]();
|
||||
uv_ip4_name(reinterpret_cast<sockaddr_in*>(addr->ai_addr), buf, 16);
|
||||
uv_ip4_name(reinterpret_cast<sockaddr_in*>(m_data), buf, 16);
|
||||
}
|
||||
|
||||
m_ip = buf;
|
||||
}
|
||||
|
||||
|
||||
sockaddr *xmrig::DnsRecord::addr(uint16_t port) const
|
||||
{
|
||||
if (m_type == A) {
|
||||
auto addr = new sockaddr_in();
|
||||
uv_ip4_addr(m_ip.data(), port, addr);
|
||||
|
||||
return reinterpret_cast<sockaddr *>(addr);
|
||||
}
|
||||
|
||||
if (m_type == AAAA) {
|
||||
auto addr = new sockaddr_in6();
|
||||
uv_ip6_addr(m_ip.data(), port, addr);
|
||||
|
||||
return reinterpret_cast<sockaddr *>(addr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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
|
||||
@@ -33,7 +33,7 @@ namespace xmrig {
|
||||
class DnsRecord
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
enum Type : uint32_t {
|
||||
Unknown,
|
||||
A,
|
||||
AAAA
|
||||
@@ -42,15 +42,15 @@ public:
|
||||
DnsRecord() {}
|
||||
DnsRecord(const addrinfo *addr);
|
||||
|
||||
sockaddr *addr(uint16_t port = 0) const;
|
||||
const sockaddr *addr(uint16_t port = 0) const;
|
||||
String ip() const;
|
||||
|
||||
inline bool isValid() const { return m_type != Unknown; }
|
||||
inline const String &ip() const { return m_ip; }
|
||||
inline Type type() const { return m_type; }
|
||||
|
||||
private:
|
||||
Type m_type = Unknown;
|
||||
String m_ip;
|
||||
mutable uint8_t m_data[28]{};
|
||||
const Type m_type = Unknown;
|
||||
};
|
||||
|
||||
|
||||
|
||||
108
src/base/net/dns/DnsRecords.cpp
Normal file
108
src/base/net/dns/DnsRecords.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that 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 <uv.h>
|
||||
|
||||
|
||||
#include "base/net/dns/DnsRecords.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
|
||||
|
||||
const xmrig::DnsRecord &xmrig::DnsRecords::get(DnsRecord::Type prefered) const
|
||||
{
|
||||
static const DnsRecord defaultRecord;
|
||||
|
||||
if (isEmpty()) {
|
||||
return defaultRecord;
|
||||
}
|
||||
|
||||
const size_t ipv4 = m_ipv4.size();
|
||||
const size_t ipv6 = m_ipv6.size();
|
||||
|
||||
if (ipv6 && (prefered == DnsRecord::AAAA || Dns::config().isIPv6() || !ipv4)) {
|
||||
return m_ipv6[ipv6 == 1 ? 0 : static_cast<size_t>(rand()) % ipv6];
|
||||
}
|
||||
|
||||
if (ipv4) {
|
||||
return m_ipv4[ipv4 == 1 ? 0 : static_cast<size_t>(rand()) % ipv4];
|
||||
}
|
||||
|
||||
return defaultRecord;
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::DnsRecords::count(DnsRecord::Type type) const
|
||||
{
|
||||
if (type == DnsRecord::A) {
|
||||
return m_ipv4.size();
|
||||
}
|
||||
|
||||
if (type == DnsRecord::AAAA) {
|
||||
return m_ipv6.size();
|
||||
}
|
||||
|
||||
return m_ipv4.size() + m_ipv6.size();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DnsRecords::clear()
|
||||
{
|
||||
m_ipv4.clear();
|
||||
m_ipv6.clear();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DnsRecords::parse(addrinfo *res)
|
||||
{
|
||||
clear();
|
||||
|
||||
addrinfo *ptr = res;
|
||||
size_t ipv4 = 0;
|
||||
size_t ipv6 = 0;
|
||||
|
||||
while (ptr != nullptr) {
|
||||
if (ptr->ai_family == AF_INET) {
|
||||
++ipv4;
|
||||
}
|
||||
else if (ptr->ai_family == AF_INET6) {
|
||||
++ipv6;
|
||||
}
|
||||
|
||||
ptr = ptr->ai_next;
|
||||
}
|
||||
|
||||
if (ipv4 == 0 && ipv6 == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_ipv4.reserve(ipv4);
|
||||
m_ipv6.reserve(ipv6);
|
||||
|
||||
ptr = res;
|
||||
while (ptr != nullptr) {
|
||||
if (ptr->ai_family == AF_INET) {
|
||||
m_ipv4.emplace_back(ptr);
|
||||
}
|
||||
else if (ptr->ai_family == AF_INET6) {
|
||||
m_ipv6.emplace_back(ptr);
|
||||
}
|
||||
|
||||
ptr = ptr->ai_next;
|
||||
}
|
||||
}
|
||||
48
src/base/net/dns/DnsRecords.h
Normal file
48
src/base/net/dns/DnsRecords.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that 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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_DNSRECORDS_H
|
||||
#define XMRIG_DNSRECORDS_H
|
||||
|
||||
|
||||
#include "base/net/dns/DnsRecord.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class DnsRecords
|
||||
{
|
||||
public:
|
||||
inline bool isEmpty() const { return m_ipv4.empty() && m_ipv6.empty(); }
|
||||
|
||||
const DnsRecord &get(DnsRecord::Type prefered = DnsRecord::Unknown) const;
|
||||
size_t count(DnsRecord::Type type = DnsRecord::Unknown) const;
|
||||
void clear();
|
||||
void parse(addrinfo *res);
|
||||
|
||||
private:
|
||||
std::vector<DnsRecord> m_ipv4;
|
||||
std::vector<DnsRecord> m_ipv6;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_DNSRECORDS_H */
|
||||
50
src/base/net/dns/DnsRequest.h
Normal file
50
src/base/net/dns/DnsRequest.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that 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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_DNSREQUEST_H
|
||||
#define XMRIG_DNSREQUEST_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IDnsListener;
|
||||
|
||||
|
||||
class DnsRequest
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(DnsRequest)
|
||||
|
||||
DnsRequest(IDnsListener *listener) : listener(listener) {}
|
||||
~DnsRequest() = default;
|
||||
|
||||
IDnsListener *listener;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_DNSREQUEST_H */
|
||||
134
src/base/net/dns/DnsUvBackend.cpp
Normal file
134
src/base/net/dns/DnsUvBackend.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that 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 <uv.h>
|
||||
|
||||
|
||||
#include "base/net/dns/DnsUvBackend.h"
|
||||
#include "base/kernel/interfaces/IDnsListener.h"
|
||||
#include "base/net/dns/DnsRequest.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
Storage<DnsUvBackend>& DnsUvBackend::getStorage()
|
||||
{
|
||||
static Storage<DnsUvBackend>* storage = new Storage<DnsUvBackend>();
|
||||
return *storage;
|
||||
}
|
||||
|
||||
static addrinfo hints{};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::DnsUvBackend::DnsUvBackend()
|
||||
{
|
||||
if (!hints.ai_protocol) {
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
}
|
||||
|
||||
m_key = getStorage().add(this);
|
||||
}
|
||||
|
||||
|
||||
xmrig::DnsUvBackend::~DnsUvBackend()
|
||||
{
|
||||
getStorage().release(m_key);
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<xmrig::DnsRequest> xmrig::DnsUvBackend::resolve(const String &host, IDnsListener *listener, uint64_t ttl)
|
||||
{
|
||||
auto req = std::make_shared<DnsRequest>(listener);
|
||||
|
||||
if (Chrono::currentMSecsSinceEpoch() - m_ts <= ttl && !m_records.isEmpty()) {
|
||||
req->listener->onResolved(m_records, 0, nullptr);
|
||||
} else {
|
||||
m_queue.emplace(req);
|
||||
}
|
||||
|
||||
if (m_queue.size() == 1 && !resolve(host)) {
|
||||
done();
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::DnsUvBackend::resolve(const String &host)
|
||||
{
|
||||
m_req = std::make_shared<uv_getaddrinfo_t>();
|
||||
m_req->data = getStorage().ptr(m_key);
|
||||
|
||||
m_status = uv_getaddrinfo(uv_default_loop(), m_req.get(), DnsUvBackend::onResolved, host.data(), nullptr, &hints);
|
||||
|
||||
return m_status == 0;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DnsUvBackend::done()
|
||||
{
|
||||
const char *error = m_status < 0 ? uv_strerror(m_status) : nullptr;
|
||||
|
||||
while (!m_queue.empty()) {
|
||||
auto req = std::move(m_queue.front()).lock();
|
||||
if (req) {
|
||||
req->listener->onResolved(m_records, m_status, error);
|
||||
}
|
||||
|
||||
m_queue.pop();
|
||||
}
|
||||
|
||||
m_req.reset();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DnsUvBackend::onResolved(int status, addrinfo *res)
|
||||
{
|
||||
m_ts = Chrono::currentMSecsSinceEpoch();
|
||||
|
||||
if ((m_status = status) < 0) {
|
||||
return done();
|
||||
}
|
||||
|
||||
m_records.parse(res);
|
||||
|
||||
if (m_records.isEmpty()) {
|
||||
m_status = UV_EAI_NONAME;
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
|
||||
|
||||
void xmrig::DnsUvBackend::onResolved(uv_getaddrinfo_t *req, int status, addrinfo *res)
|
||||
{
|
||||
auto backend = getStorage().get(req->data);
|
||||
if (backend) {
|
||||
backend->onResolved(status, res);
|
||||
}
|
||||
|
||||
uv_freeaddrinfo(res);
|
||||
}
|
||||
71
src/base/net/dns/DnsUvBackend.h
Normal file
71
src/base/net/dns/DnsUvBackend.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that 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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_DNSUVBACKEND_H
|
||||
#define XMRIG_DNSUVBACKEND_H
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IDnsBackend.h"
|
||||
#include "base/net/dns/DnsRecords.h"
|
||||
#include "base/net/tools/Storage.h"
|
||||
|
||||
|
||||
#include <queue>
|
||||
|
||||
|
||||
using uv_getaddrinfo_t = struct uv_getaddrinfo_s;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class DnsUvBackend : public IDnsBackend
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(DnsUvBackend)
|
||||
|
||||
DnsUvBackend();
|
||||
~DnsUvBackend() override;
|
||||
|
||||
protected:
|
||||
inline const DnsRecords &records() const override { return m_records; }
|
||||
|
||||
std::shared_ptr<DnsRequest> resolve(const String &host, IDnsListener *listener, uint64_t ttl) override;
|
||||
|
||||
private:
|
||||
bool resolve(const String &host);
|
||||
void done();
|
||||
void onResolved(int status, addrinfo *res);
|
||||
|
||||
static void onResolved(uv_getaddrinfo_t *req, int status, addrinfo *res);
|
||||
|
||||
DnsRecords m_records;
|
||||
int m_status = 0;
|
||||
std::queue<std::weak_ptr<DnsRequest> > m_queue;
|
||||
std::shared_ptr<uv_getaddrinfo_t> m_req;
|
||||
uint64_t m_ts = 0;
|
||||
uintptr_t m_key;
|
||||
|
||||
static Storage<DnsUvBackend>& getStorage();
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_DNSUVBACKEND_H */
|
||||
@@ -23,11 +23,13 @@
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/dns/DnsRecords.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/tools/Timer.h"
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -48,7 +50,6 @@ xmrig::HttpClient::HttpClient(const char *tag, FetchRequest &&req, const std::we
|
||||
url = std::move(m_req.path);
|
||||
body = std::move(m_req.body);
|
||||
headers = std::move(m_req.headers);
|
||||
m_dns = std::make_shared<Dns>(this);
|
||||
|
||||
if (m_req.timeout) {
|
||||
m_timer = std::make_shared<Timer>(this, m_req.timeout, 0);
|
||||
@@ -58,30 +59,29 @@ xmrig::HttpClient::HttpClient(const char *tag, FetchRequest &&req, const std::we
|
||||
|
||||
bool xmrig::HttpClient::connect()
|
||||
{
|
||||
return m_dns->resolve(m_req.host);
|
||||
m_dns = Dns::resolve(m_req.host, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpClient::onResolved(const Dns &dns, int status)
|
||||
void xmrig::HttpClient::onResolved(const DnsRecords &records, int status, const char *error)
|
||||
{
|
||||
this->status = status;
|
||||
m_dns.reset();
|
||||
|
||||
if (status < 0 && dns.isEmpty()) {
|
||||
if (status < 0 && records.isEmpty()) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("%s " RED("DNS error: ") RED_BOLD("\"%s\""), tag(), uv_strerror(status));
|
||||
LOG_ERR("%s " RED("DNS error: ") RED_BOLD("\"%s\""), tag(), error);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sockaddr *addr = dns.get().addr(port());
|
||||
|
||||
auto req = new uv_connect_t;
|
||||
req->data = this;
|
||||
|
||||
uv_tcp_connect(req, m_tcp, addr, onConnect);
|
||||
|
||||
delete addr;
|
||||
uv_tcp_connect(req, m_tcp, records.get().addr(port()), onConnect);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ void xmrig::HttpClient::handshake()
|
||||
|
||||
void xmrig::HttpClient::read(const char *data, size_t size)
|
||||
{
|
||||
if (parse(data, size) < size) {
|
||||
if (!parse(data, size)) {
|
||||
close(UV_EPROTO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class String;
|
||||
class DnsRequest;
|
||||
|
||||
|
||||
class HttpClient : public HttpContext, public IDnsListener, public ITimerListener
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
bool connect();
|
||||
|
||||
protected:
|
||||
void onResolved(const Dns &dns, int status) override;
|
||||
void onResolved(const DnsRecords &records, int status, const char *error) override;
|
||||
void onTimer(const Timer *timer) override;
|
||||
|
||||
virtual void handshake();
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
|
||||
const char *m_tag;
|
||||
FetchRequest m_req;
|
||||
std::shared_ptr<Dns> m_dns;
|
||||
std::shared_ptr<DnsRequest> m_dns;
|
||||
std::shared_ptr<Timer> m_timer;
|
||||
};
|
||||
|
||||
|
||||
@@ -118,13 +118,13 @@ bool xmrig::HttpContext::isRequest() const
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::HttpContext::parse(const char *data, size_t size)
|
||||
bool xmrig::HttpContext::parse(const char *data, size_t size)
|
||||
{
|
||||
if (size == 0) {
|
||||
return size;
|
||||
return true;
|
||||
}
|
||||
|
||||
return llhttp_execute(m_parser, data, size);
|
||||
return llhttp_execute(m_parser, data, size) == HPE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
void write(std::string &&data, bool close) override;
|
||||
|
||||
bool isRequest() const override;
|
||||
size_t parse(const char *data, size_t size);
|
||||
bool parse(const char *data, size_t size);
|
||||
std::string ip() const override;
|
||||
uint64_t elapsed() const;
|
||||
void close(int status = 0);
|
||||
|
||||
@@ -50,14 +50,7 @@ void xmrig::HttpServer::onConnection(uv_stream_t *stream, uint16_t)
|
||||
{
|
||||
auto ctx = static_cast<HttpContext*>(tcp->data);
|
||||
|
||||
if (nread >= 0) {
|
||||
const auto size = static_cast<size_t>(nread);
|
||||
const auto parsed = ctx->parse(buf->base, size);
|
||||
|
||||
if (parsed < size) {
|
||||
ctx->close();
|
||||
}
|
||||
} else {
|
||||
if (nread < 0 || !ctx->parse(buf->base, static_cast<size_t>(nread))) {
|
||||
ctx->close();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ bool xmrig::HttpsContext::write(BIO *bio)
|
||||
|
||||
void xmrig::HttpsContext::parse(char *data, size_t size)
|
||||
{
|
||||
if (HttpContext::parse(data, size) < size) {
|
||||
if (!HttpContext::parse(data, size)) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +48,11 @@
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/dns/DnsRecords.h"
|
||||
#include "base/net/stratum/Socks5.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Cvt.h"
|
||||
#include "net/JobResult.h"
|
||||
|
||||
|
||||
@@ -86,13 +87,11 @@ xmrig::Client::Client(int id, const char *agent, IClientListener *listener) :
|
||||
{
|
||||
m_reader.setListener(this);
|
||||
m_key = m_storage.add(this);
|
||||
m_dns = new Dns(this);
|
||||
}
|
||||
|
||||
|
||||
xmrig::Client::~Client()
|
||||
{
|
||||
delete m_dns;
|
||||
delete m_socket;
|
||||
}
|
||||
|
||||
@@ -295,22 +294,24 @@ void xmrig::Client::tick(uint64_t now)
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Client::onResolved(const Dns &dns, int status)
|
||||
void xmrig::Client::onResolved(const DnsRecords &records, int status, const char *error)
|
||||
{
|
||||
m_dns.reset();
|
||||
|
||||
assert(m_listener != nullptr);
|
||||
if (!m_listener) {
|
||||
return reconnect();
|
||||
}
|
||||
|
||||
if (status < 0 && dns.isEmpty()) {
|
||||
if (status < 0 && records.isEmpty()) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("%s " RED("DNS error: ") RED_BOLD("\"%s\""), tag(), uv_strerror(status));
|
||||
LOG_ERR("%s " RED("DNS error: ") RED_BOLD("\"%s\""), tag(), error);
|
||||
}
|
||||
|
||||
return reconnect();
|
||||
}
|
||||
|
||||
const auto &record = dns.get();
|
||||
const auto &record = records.get();
|
||||
m_ip = record.ip();
|
||||
|
||||
connect(record.addr(m_socks5 ? m_pool.proxy().port() : m_pool.port()));
|
||||
@@ -377,6 +378,19 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *algo = Json::getString(params, "algo");
|
||||
const char *blobData = Json::getString(params, "blob");
|
||||
if (algo) {
|
||||
job.setAlgorithm(algo);
|
||||
}
|
||||
else if (m_pool.coin().isValid()) {
|
||||
uint8_t blobVersion = 0;
|
||||
if (blobData) {
|
||||
Cvt::fromHex(&blobVersion, 1, blobData, 2);
|
||||
}
|
||||
job.setAlgorithm(m_pool.coin().algorithm(blobVersion));
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (m_pool.mode() == Pool::MODE_SELF_SELECT) {
|
||||
job.setExtraNonce(Json::getString(params, "extra_nonce"));
|
||||
@@ -390,7 +404,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
else
|
||||
# endif
|
||||
{
|
||||
if (!job.setBlob(params["blob"].GetString())) {
|
||||
if (!job.setBlob(blobData)) {
|
||||
*code = 4;
|
||||
return false;
|
||||
}
|
||||
@@ -401,14 +415,6 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *algo = Json::getString(params, "algo");
|
||||
if (algo) {
|
||||
job.setAlgorithm(algo);
|
||||
}
|
||||
else if (m_pool.coin().isValid()) {
|
||||
job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0]));
|
||||
}
|
||||
|
||||
job.setHeight(Json::getUint64(params, "height"));
|
||||
|
||||
if (!verifyAlgorithm(job.algorithm(), algo)) {
|
||||
@@ -524,13 +530,7 @@ int xmrig::Client::resolve(const String &host)
|
||||
m_failures = 0;
|
||||
}
|
||||
|
||||
if (!m_dns->resolve(host)) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("%s " RED("getaddrinfo error: ") RED_BOLD("\"%s\""), tag(), uv_strerror(m_dns->status()));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
m_dns = Dns::resolve(host, this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -566,7 +566,7 @@ int64_t xmrig::Client::send(size_t size)
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Client::connect(sockaddr *addr)
|
||||
void xmrig::Client::connect(const sockaddr *addr)
|
||||
{
|
||||
setState(ConnectingState);
|
||||
|
||||
@@ -584,8 +584,6 @@ void xmrig::Client::connect(sockaddr *addr)
|
||||
# endif
|
||||
|
||||
uv_tcp_connect(req, m_socket, addr, onConnect);
|
||||
|
||||
delete addr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ using BIO = struct bio_st;
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class DnsRequest;
|
||||
class IClientListener;
|
||||
class JobResult;
|
||||
|
||||
@@ -79,7 +80,7 @@ protected:
|
||||
void deleteLater() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
||||
void onResolved(const Dns &dns, int status) override;
|
||||
void onResolved(const DnsRecords &records, int status, const char *error) override;
|
||||
|
||||
inline bool hasExtension(Extension extension) const noexcept override { return m_extensions.test(extension); }
|
||||
inline const char *mode() const override { return "pool"; }
|
||||
@@ -108,7 +109,7 @@ private:
|
||||
bool write(const uv_buf_t &buf);
|
||||
int resolve(const String &host);
|
||||
int64_t send(size_t size);
|
||||
void connect(sockaddr *addr);
|
||||
void connect(const sockaddr *addr);
|
||||
void handshake();
|
||||
void parse(char *line, size_t len);
|
||||
void parseExtensions(const rapidjson::Value &result);
|
||||
@@ -131,10 +132,10 @@ private:
|
||||
static inline Client *getClient(void *data) { return m_storage.get(data); }
|
||||
|
||||
const char *m_agent;
|
||||
Dns *m_dns;
|
||||
LineReader m_reader;
|
||||
Socks5 *m_socks5 = nullptr;
|
||||
std::bitset<EXT_MAX> m_extensions;
|
||||
std::shared_ptr<DnsRequest> m_dns;
|
||||
std::vector<char> m_sendBuf;
|
||||
String m_rpcId;
|
||||
Tls *m_tls = nullptr;
|
||||
|
||||
@@ -247,6 +247,12 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
Cvt::toHex(m_blockhashingblob.data() + offset * 2, kBlobReserveSize * 2, Cvt::randomBytes(kBlobReserveSize).data(), kBlobReserveSize);
|
||||
}
|
||||
|
||||
if (m_pool.coin().isValid()) {
|
||||
uint8_t blobVersion = 0;
|
||||
Cvt::fromHex(&blobVersion, 1, m_blockhashingblob.data(), 2);
|
||||
job.setAlgorithm(m_pool.coin().algorithm(blobVersion));
|
||||
}
|
||||
|
||||
if (blocktemplate.isNull() || !job.setBlob(m_blockhashingblob)) {
|
||||
*code = 4;
|
||||
return false;
|
||||
@@ -257,10 +263,6 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code)
|
||||
job.setDiff(Json::getUint64(params, "difficulty"));
|
||||
job.setId(blocktemplate.data() + blocktemplate.size() - 32);
|
||||
|
||||
if (m_pool.coin().isValid()) {
|
||||
job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0]));
|
||||
}
|
||||
|
||||
m_job = std::move(job);
|
||||
m_blocktemplate = std::move(blocktemplate);
|
||||
m_prevHash = Json::getString(params, "prev_hash");
|
||||
|
||||
@@ -130,12 +130,17 @@ bool xmrig::SelfSelectClient::parseResponse(int64_t id, rapidjson::Value &result
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_job.setBlob(result[kBlockhashingBlob].GetString())) {
|
||||
return false;
|
||||
const char *blobData = Json::getString(result, kBlockhashingBlob);
|
||||
if (pool().coin().isValid()) {
|
||||
uint8_t blobVersion = 0;
|
||||
if (blobData) {
|
||||
Cvt::fromHex(&blobVersion, 1, blobData, 2);
|
||||
}
|
||||
m_job.setAlgorithm(pool().coin().algorithm(blobVersion));
|
||||
}
|
||||
|
||||
if (pool().coin().isValid()) {
|
||||
m_job.setAlgorithm(pool().coin().algorithm(m_job.blob()[0]));
|
||||
if (!m_job.setBlob(blobData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_job.setHeight(Json::getUint64(result, kHeight));
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/dns/DnsRecords.h"
|
||||
#include "base/net/http/Fetch.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
#include "base/net/http/HttpListener.h"
|
||||
@@ -47,8 +48,8 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, I
|
||||
std::vector<char> blob(112 * 2 + 1, '0');
|
||||
blob.back() = '\0';
|
||||
|
||||
m_job.setBlob(blob.data());
|
||||
m_job.setAlgorithm(m_benchmark->algorithm());
|
||||
m_job.setBlob(blob.data());
|
||||
m_job.setDiff(std::numeric_limits<uint64_t>::max());
|
||||
m_job.setHeight(1);
|
||||
m_job.setId("00000000");
|
||||
@@ -185,16 +186,18 @@ void xmrig::BenchClient::onHttpData(const HttpData &data)
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BenchClient::onResolved(const Dns &dns, int status)
|
||||
void xmrig::BenchClient::onResolved(const DnsRecords &records, int status, const char *error)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
assert(!m_httpListener);
|
||||
|
||||
m_dns.reset();
|
||||
|
||||
if (status < 0) {
|
||||
return setError(dns.error(), "DNS error");
|
||||
return setError(error, "DNS error");
|
||||
}
|
||||
|
||||
m_ip = dns.get().ip();
|
||||
m_ip = records.get().ip();
|
||||
m_httpListener = std::make_shared<HttpListener>(this, tag());
|
||||
|
||||
if (m_mode == ONLINE_BENCH) {
|
||||
@@ -307,11 +310,7 @@ void xmrig::BenchClient::onGetReply(const rapidjson::Value &value)
|
||||
|
||||
void xmrig::BenchClient::resolve()
|
||||
{
|
||||
m_dns = std::make_shared<Dns>(this);
|
||||
|
||||
if (!m_dns->resolve(BenchConfig::kApiHost)) {
|
||||
setError(m_dns->error(), "getaddrinfo error");
|
||||
}
|
||||
m_dns = Dns::resolve(BenchConfig::kApiHost, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -335,6 +334,7 @@ void xmrig::BenchClient::send(Request request)
|
||||
{
|
||||
doc.AddMember(StringRef(BenchConfig::kSize), m_benchmark->size(), allocator);
|
||||
doc.AddMember(StringRef(BenchConfig::kAlgo), m_benchmark->algorithm().toJSON(), allocator);
|
||||
doc.AddMember(StringRef(BenchConfig::kUser), m_benchmark->user().toJSON(), allocator);
|
||||
doc.AddMember("version", APP_VERSION, allocator);
|
||||
doc.AddMember("threads", m_threads, allocator);
|
||||
doc.AddMember("steady_ready_ts", m_readyTime, allocator);
|
||||
|
||||
@@ -70,7 +70,7 @@ protected:
|
||||
void onBenchDone(uint64_t result, uint64_t diff, uint64_t ts) override;
|
||||
void onBenchReady(uint64_t ts, uint32_t threads, const IBackend *backend) override;
|
||||
void onHttpData(const HttpData &data) override;
|
||||
void onResolved(const Dns &dns, int status) override;
|
||||
void onResolved(const DnsRecords &records, int status, const char *error) override;
|
||||
|
||||
private:
|
||||
enum Mode : uint32_t {
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
Pool m_pool;
|
||||
Request m_request = NO_REQUEST;
|
||||
std::shared_ptr<BenchConfig> m_benchmark;
|
||||
std::shared_ptr<Dns> m_dns;
|
||||
std::shared_ptr<DnsRequest> m_dns;
|
||||
std::shared_ptr<IHttpListener> m_httpListener;
|
||||
String m_ip;
|
||||
String m_token;
|
||||
|
||||
@@ -41,6 +41,7 @@ const char *BenchConfig::kSeed = "seed";
|
||||
const char *BenchConfig::kSize = "size";
|
||||
const char *BenchConfig::kSubmit = "submit";
|
||||
const char *BenchConfig::kToken = "token";
|
||||
const char *BenchConfig::kUser = "user";
|
||||
const char *BenchConfig::kVerify = "verify";
|
||||
|
||||
#ifndef XMRIG_DEBUG_BENCHMARK_API
|
||||
@@ -59,8 +60,8 @@ xmrig::BenchConfig::BenchConfig(uint32_t size, const String &id, const rapidjson
|
||||
m_id(id),
|
||||
m_seed(Json::getString(object, kSeed)),
|
||||
m_token(Json::getString(object, kToken)),
|
||||
m_size(size),
|
||||
m_hash(0)
|
||||
m_user(Json::getString(object, kUser)),
|
||||
m_size(size)
|
||||
{
|
||||
if (!m_algorithm.isValid() || m_algorithm.family() != Algorithm::RANDOM_X) {
|
||||
m_algorithm = Algorithm::RX_0;
|
||||
@@ -111,6 +112,7 @@ rapidjson::Value xmrig::BenchConfig::toJSON(rapidjson::Document &doc) const
|
||||
out.AddMember(StringRef(kVerify), m_id.toJSON(), allocator);
|
||||
out.AddMember(StringRef(kToken), m_token.toJSON(), allocator);
|
||||
out.AddMember(StringRef(kSeed), m_seed.toJSON(), allocator);
|
||||
out.AddMember(StringRef(kUser), m_user.toJSON(), allocator);
|
||||
|
||||
if (m_hash) {
|
||||
out.AddMember(StringRef(kHash), Value(fmt::format("{:016X}", m_hash).c_str(), allocator), allocator);
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
static const char *kSize;
|
||||
static const char *kSubmit;
|
||||
static const char *kToken;
|
||||
static const char *kUser;
|
||||
static const char *kVerify;
|
||||
|
||||
# ifndef XMRIG_DEBUG_BENCHMARK_API
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
inline const String &id() const { return m_id; }
|
||||
inline const String &seed() const { return m_seed; }
|
||||
inline const String &token() const { return m_token; }
|
||||
inline const String &user() const { return m_user; }
|
||||
inline uint32_t size() const { return m_size; }
|
||||
inline uint64_t hash() const { return m_hash; }
|
||||
|
||||
@@ -73,8 +75,9 @@ private:
|
||||
String m_id;
|
||||
String m_seed;
|
||||
String m_token;
|
||||
String m_user;
|
||||
uint32_t m_size;
|
||||
uint64_t m_hash;
|
||||
uint64_t m_hash = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
uv_close(reinterpret_cast<uv_handle_t *>(handle), [](uv_handle_t *handle) { delete handle; });
|
||||
uv_close(reinterpret_cast<uv_handle_t *>(handle), [](uv_handle_t *handle) { delete reinterpret_cast<T>(handle); });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "backend/cpu/Cpu.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/interfaces/IJsonReader.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
|
||||
|
||||
@@ -295,6 +296,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
doc.AddMember(StringRef(kTls), m_tls.toJSON(doc), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember(StringRef(DnsConfig::kField), Dns::config().toJSON(doc), allocator);
|
||||
doc.AddMember(StringRef(kUserAgent), m_userAgent.toJSON(), allocator);
|
||||
doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator);
|
||||
doc.AddMember(StringRef(kWatch), m_watch, allocator);
|
||||
|
||||
@@ -262,6 +262,7 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
|
||||
case IConfig::BenchTokenKey: /* --token */
|
||||
case IConfig::BenchSeedKey: /* --seed */
|
||||
case IConfig::BenchHashKey: /* --hash */
|
||||
case IConfig::UserKey: /* --user */
|
||||
return transformBenchmark(doc, key, arg);
|
||||
# endif
|
||||
|
||||
@@ -347,6 +348,9 @@ void xmrig::ConfigTransform::transformBenchmark(rapidjson::Document &doc, int ke
|
||||
|
||||
case IConfig::BenchHashKey: /* --hash */
|
||||
return set(doc, BenchConfig::kBenchmark, BenchConfig::kHash, arg);
|
||||
|
||||
case IConfig::UserKey: /* --user */
|
||||
return set(doc, BenchConfig::kBenchmark, BenchConfig::kUser, arg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -93,7 +93,9 @@ static const option options[] = {
|
||||
{ "title", 1, nullptr, IConfig::TitleKey },
|
||||
{ "no-title", 0, nullptr, IConfig::NoTitleKey },
|
||||
{ "pause-on-battery", 0, nullptr, IConfig::PauseOnBatteryKey },
|
||||
{ "pause-on-active", 1, nullptr, IConfig::PauseOnActiveKey },
|
||||
{ "pause-on-active", 1, nullptr, IConfig::PauseOnActiveKey },
|
||||
{ "dns-ipv6", 0, nullptr, IConfig::DnsIPv6Key },
|
||||
{ "dns-ttl", 1, nullptr, IConfig::DnsTtlKey },
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
{ "stress", 0, nullptr, IConfig::StressKey },
|
||||
{ "bench", 1, nullptr, IConfig::BenchKey },
|
||||
|
||||
@@ -59,6 +59,9 @@ static inline const std::string &usage()
|
||||
u += " --tls-fingerprint=HEX pool TLS certificate fingerprint for strict certificate pinning\n";
|
||||
# endif
|
||||
|
||||
u += " --dns-ipv6 prefer IPv6 records from DNS responses\n";
|
||||
u += " --dns-ttl=N N seconds (default: 30) TTL for internal DNS cache\n";
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
u += " --daemon use daemon RPC instead of pool for solo mining\n";
|
||||
u += " --daemon-poll-interval=N daemon poll interval in milliseconds (default: 1000)\n";
|
||||
|
||||
@@ -96,6 +96,11 @@ public:
|
||||
return CN_ITER / 8;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
case Algorithm::CN_UPX2:
|
||||
return CN_ITER / 32;
|
||||
# endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -111,6 +116,12 @@ public:
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
if (algo == Algorithm::CN_UPX2) {
|
||||
return 0x1FFF0;
|
||||
}
|
||||
# endif
|
||||
|
||||
return ((memory(algo) - 1) / 16) * 16;
|
||||
}
|
||||
|
||||
@@ -149,6 +160,9 @@ public:
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
case Algorithm::CN_PICO_0:
|
||||
case Algorithm::CN_PICO_TLO:
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
case Algorithm::CN_UPX2:
|
||||
# endif
|
||||
return Algorithm::CN_2;
|
||||
|
||||
@@ -176,6 +190,7 @@ template<> constexpr inline Algorithm::Id CnAlgo<Algorithm::CN_FAST>::base() con
|
||||
template<> constexpr inline Algorithm::Id CnAlgo<Algorithm::CN_RTO>::base() const { return Algorithm::CN_1; }
|
||||
template<> constexpr inline Algorithm::Id CnAlgo<Algorithm::CN_LITE_1>::base() const { return Algorithm::CN_1; }
|
||||
template<> constexpr inline Algorithm::Id CnAlgo<Algorithm::CN_HEAVY_TUBE>::base() const { return Algorithm::CN_1; }
|
||||
template<> constexpr inline Algorithm::Id CnAlgo<Algorithm::CN_UPX2>::base() const { return Algorithm::CN_2; }
|
||||
|
||||
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_FAST>::iterations() const { return CN_ITER / 2; }
|
||||
@@ -192,6 +207,7 @@ template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_ZLS>::iterations() con
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::iterations() const { return CN_ITER / 8; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_TLO>::iterations() const { return CN_ITER / 8; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_CCX>::iterations() const { return CN_ITER / 2; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_UPX2>::iterations() const { return CN_ITER / 32; }
|
||||
|
||||
|
||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_LITE_0>::memory() const { return CN_MEMORY / 2; }
|
||||
@@ -201,9 +217,11 @@ template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_TUBE>::memory() co
|
||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_XHV>::memory() const { return CN_MEMORY * 2; }
|
||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_PICO_0>::memory() const { return CN_MEMORY / 8; }
|
||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_PICO_TLO>::memory() const { return CN_MEMORY / 8; }
|
||||
template<> constexpr inline size_t CnAlgo<Algorithm::CN_UPX2>::memory() const { return CN_MEMORY / 16; }
|
||||
|
||||
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::mask() const { return 0x1FFF0; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_UPX2>::mask() const { return 0x1FFF0; }
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
@@ -99,8 +99,11 @@ cn_mainloop_fun cn_double_mainloop_ryzen_asm = nullptr;
|
||||
cn_mainloop_fun cn_double_mainloop_bulldozer_asm = nullptr;
|
||||
cn_mainloop_fun cn_double_double_mainloop_sandybridge_asm = nullptr;
|
||||
|
||||
cn_mainloop_fun cn_upx2_mainloop_asm = nullptr;
|
||||
cn_mainloop_fun cn_upx2_double_mainloop_asm = nullptr;
|
||||
|
||||
template<typename T, typename U>
|
||||
|
||||
template<Algorithm::Id SOURCE_ALGO = Algorithm::CN_2, typename T, typename U>
|
||||
static void patchCode(T dst, U src, const uint32_t iterations, const uint32_t mask = CnAlgo<Algorithm::CN_HALF>().mask())
|
||||
{
|
||||
auto p = reinterpret_cast<const uint8_t*>(src);
|
||||
@@ -124,11 +127,11 @@ static void patchCode(T dst, U src, const uint32_t iterations, const uint32_t ma
|
||||
auto patched_data = reinterpret_cast<uint8_t*>(dst);
|
||||
for (size_t i = 0; i + sizeof(uint32_t) <= size; ++i) {
|
||||
switch (*(uint32_t*)(patched_data + i)) {
|
||||
case CnAlgo<Algorithm::CN_2>().iterations():
|
||||
case CnAlgo<SOURCE_ALGO>().iterations():
|
||||
*(uint32_t*)(patched_data + i) = iterations;
|
||||
break;
|
||||
|
||||
case CnAlgo<Algorithm::CN_2>().mask():
|
||||
case CnAlgo<SOURCE_ALGO>().mask():
|
||||
*(uint32_t*)(patched_data + i) = mask;
|
||||
break;
|
||||
}
|
||||
@@ -138,7 +141,7 @@ static void patchCode(T dst, U src, const uint32_t iterations, const uint32_t ma
|
||||
|
||||
static void patchAsmVariants()
|
||||
{
|
||||
const int allocation_size = 81920;
|
||||
const int allocation_size = 131072;
|
||||
auto base = static_cast<uint8_t *>(VirtualMemory::allocateExecutableMemory(allocation_size, false));
|
||||
|
||||
cn_half_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0000);
|
||||
@@ -170,6 +173,11 @@ static void patchAsmVariants()
|
||||
cn_tlo_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x13000);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
cn_upx2_mainloop_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x14000);
|
||||
cn_upx2_double_mainloop_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x15000);
|
||||
# endif
|
||||
|
||||
{
|
||||
constexpr uint32_t ITER = CnAlgo<Algorithm::CN_HALF>().iterations();
|
||||
|
||||
@@ -219,6 +227,16 @@ static void patchAsmVariants()
|
||||
patchCode(cn_double_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, ITER);
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
{
|
||||
constexpr uint32_t ITER = CnAlgo<Algorithm::CN_UPX2>().iterations();
|
||||
constexpr uint32_t MASK = CnAlgo<Algorithm::CN_UPX2>().mask();
|
||||
|
||||
patchCode<Algorithm::CN_RWZ>(cn_upx2_mainloop_asm, cnv2_rwz_mainloop_asm, ITER, MASK);
|
||||
patchCode<Algorithm::CN_RWZ>(cn_upx2_double_mainloop_asm, cnv2_rwz_double_mainloop_asm, ITER, MASK);
|
||||
}
|
||||
#endif
|
||||
|
||||
VirtualMemory::protectRX(base, allocation_size);
|
||||
VirtualMemory::flushInstructionCache(base, allocation_size);
|
||||
}
|
||||
@@ -272,6 +290,11 @@ xmrig::CnHash::CnHash()
|
||||
|
||||
ADD_FN(Algorithm::CN_CCX);
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
ADD_FN(Algorithm::CN_UPX2);
|
||||
ADD_FN_ASM(Algorithm::CN_UPX2);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
m_map[Algorithm::AR2_CHUKWA][AV_SINGLE][Assembly::NONE] = argon2::single_hash<Algorithm::AR2_CHUKWA>;
|
||||
m_map[Algorithm::AR2_CHUKWA][AV_SINGLE_SOFT][Assembly::NONE] = argon2::single_hash<Algorithm::AR2_CHUKWA>;
|
||||
|
||||
@@ -395,7 +395,7 @@ static inline void cryptonight_monero_tweak(const uint8_t* l, uint64_t idx, __m1
|
||||
uint64_t* mem_out = (uint64_t*)&l[idx];
|
||||
|
||||
if (props.base() == Algorithm::CN_2) {
|
||||
VARIANT2_SHUFFLE(l, idx, ax0, bx0, bx1, cx, (ALGO == Algorithm::CN_RWZ ? 1 : 0));
|
||||
VARIANT2_SHUFFLE(l, idx, ax0, bx0, bx1, cx, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0));
|
||||
_mm_store_si128((__m128i *)mem_out, _mm_xor_si128(bx0, cx));
|
||||
} else {
|
||||
__m128i tmp = _mm_xor_si128(bx0, cx);
|
||||
@@ -528,7 +528,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
||||
if (ALGO == Algorithm::CN_R) {
|
||||
VARIANT2_SHUFFLE(l0, idx0 & MASK, ax0, bx0, bx1, cx, 0);
|
||||
} else {
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx0, bx1, hi, lo, (ALGO == Algorithm::CN_RWZ ? 1 : 0));
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx0, bx1, hi, lo, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
||||
if (ALGO == Algorithm::CN_R) {
|
||||
VARIANT2_SHUFFLE(l0, idx0 & MASK, ax0, bx00, bx01, cx0, 0);
|
||||
} else {
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx00, bx01, hi, lo, (ALGO == Algorithm::CN_RWZ ? 1 : 0));
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx00, bx01, hi, lo, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
||||
if (ALGO == Algorithm::CN_R) {
|
||||
VARIANT2_SHUFFLE(l1, idx1 & MASK, ax1, bx10, bx11, cx1, 0);
|
||||
} else {
|
||||
VARIANT2_SHUFFLE2(l1, idx1 & MASK, ax1, bx10, bx11, hi, lo, (ALGO == Algorithm::CN_RWZ ? 1 : 0));
|
||||
VARIANT2_SHUFFLE2(l1, idx1 & MASK, ax1, bx10, bx11, hi, lo, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,8 +190,8 @@
|
||||
r##part[1] = static_cast<uint32_t>(h##part[12] >> 32); \
|
||||
r##part[2] = static_cast<uint32_t>(h##part[13]); \
|
||||
r##part[3] = static_cast<uint32_t>(h##part[13] >> 32); \
|
||||
} \
|
||||
v4_random_math_init<ALGO>(code##part, height);
|
||||
v4_random_math_init<ALGO>(code##part, height); \
|
||||
}
|
||||
|
||||
#define VARIANT4_RANDOM_MATH(part, al, ah, cl, bx0, bx1) \
|
||||
if (props.isR()) { \
|
||||
|
||||
@@ -370,6 +370,23 @@ const static uint8_t test_output_pico_tlo[160] = {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_FEMTO
|
||||
// "cn/upx2"
|
||||
const static uint8_t test_output_femto_upx2[160] = {
|
||||
0xAA, 0xBB, 0xB8, 0xED, 0x14, 0xA8, 0x35, 0xFA, 0x22, 0xCF, 0xB1, 0xB5, 0xDE, 0xA8, 0x72, 0xB0,
|
||||
0xA1, 0xD6, 0xCB, 0xD8, 0x46, 0xF4, 0x39, 0x1C, 0x0F, 0x01, 0xF3, 0x87, 0x5E, 0x3A, 0x37, 0x61,
|
||||
0x38, 0x59, 0x15, 0x72, 0xF8, 0x20, 0xD4, 0xDE, 0x25, 0x3C, 0xF5, 0x5A, 0x21, 0x92, 0xB6, 0x22,
|
||||
0xB0, 0x28, 0x9E, 0x2E, 0x5C, 0x36, 0x16, 0xE6, 0x1E, 0x78, 0x7A, 0x8F, 0xE4, 0x62, 0xEC, 0x5A,
|
||||
0xFD, 0x58, 0xCC, 0x6F, 0x3C, 0xD3, 0x8A, 0x0B, 0x5B, 0x6C, 0x83, 0x4E, 0x9B, 0xD4, 0xC2, 0x5A,
|
||||
0x43, 0x2C, 0x48, 0x98, 0xF3, 0x16, 0xCA, 0x87, 0xE9, 0x5F, 0x44, 0x93, 0x53, 0x48, 0x00, 0xA3,
|
||||
0xE8, 0xE4, 0xB6, 0x9D, 0x5A, 0x3B, 0x49, 0x2C, 0x21, 0xE9, 0x4B, 0x02, 0xFC, 0x87, 0x8D, 0x75,
|
||||
0x66, 0x05, 0xAF, 0xA3, 0x9D, 0xC9, 0xD8, 0x88, 0x2D, 0x67, 0x31, 0x21, 0x4C, 0x4D, 0x88, 0x7D,
|
||||
0x86, 0x9E, 0x4D, 0x74, 0xF4, 0x4C, 0x57, 0x27, 0xCF, 0xEF, 0x86, 0x01, 0xB0, 0x52, 0x18, 0xF3,
|
||||
0xAD, 0xE4, 0x52, 0x5E, 0xB0, 0x4A, 0x97, 0xB4, 0x96, 0x18, 0xB6, 0x9C, 0x93, 0x0E, 0x49, 0xBB,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_ARGON2
|
||||
// "argon2/chukwa"
|
||||
const static uint8_t argon2_chukwa_test_out[160] = {
|
||||
|
||||
@@ -377,12 +377,15 @@ static inline void cn_explode_scratchpad(const __m128i *input, __m128i *output)
|
||||
_mm_store_si128(output + 1, xin1);
|
||||
_mm_store_si128(output + 2, xin2);
|
||||
_mm_store_si128(output + 3, xin3);
|
||||
output += (64 << interleave) / sizeof(__m128i);
|
||||
_mm_store_si128(output + 0, xin4);
|
||||
_mm_store_si128(output + 1, xin5);
|
||||
_mm_store_si128(output + 2, xin6);
|
||||
_mm_store_si128(output + 3, xin7);
|
||||
output += (64 << interleave) / sizeof(__m128i);
|
||||
|
||||
constexpr int output_increment = (64 << interleave) / sizeof(__m128i);
|
||||
|
||||
_mm_store_si128(output + output_increment + 0, xin4);
|
||||
_mm_store_si128(output + output_increment + 1, xin5);
|
||||
_mm_store_si128(output + output_increment + 2, xin6);
|
||||
_mm_store_si128(output + output_increment + 3, xin7);
|
||||
|
||||
output += output_increment * 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,13 +417,15 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output)
|
||||
xout1 = _mm_xor_si128(_mm_load_si128(input + 1), xout1);
|
||||
xout2 = _mm_xor_si128(_mm_load_si128(input + 2), xout2);
|
||||
xout3 = _mm_xor_si128(_mm_load_si128(input + 3), xout3);
|
||||
input += (64 << interleave) / sizeof(__m128i);
|
||||
xout4 = _mm_xor_si128(_mm_load_si128(input + 0), xout4);
|
||||
xout5 = _mm_xor_si128(_mm_load_si128(input + 1), xout5);
|
||||
xout6 = _mm_xor_si128(_mm_load_si128(input + 2), xout6);
|
||||
xout7 = _mm_xor_si128(_mm_load_si128(input + 3), xout7);
|
||||
input += (64 << interleave) / sizeof(__m128i);
|
||||
|
||||
constexpr int input_increment = (64 << interleave) / sizeof(__m128i);
|
||||
|
||||
xout4 = _mm_xor_si128(_mm_load_si128(input + input_increment + 0), xout4);
|
||||
xout5 = _mm_xor_si128(_mm_load_si128(input + input_increment + 1), xout5);
|
||||
xout6 = _mm_xor_si128(_mm_load_si128(input + input_increment + 2), xout6);
|
||||
xout7 = _mm_xor_si128(_mm_load_si128(input + input_increment + 3), xout7);
|
||||
|
||||
input += input_increment * 2;
|
||||
i += 8;
|
||||
|
||||
if ((interleave > 0) && (i < props.memory() / sizeof(__m128i))) {
|
||||
@@ -563,7 +568,7 @@ static inline void cryptonight_monero_tweak(uint64_t *mem_out, const uint8_t *l,
|
||||
constexpr CnAlgo<ALGO> props;
|
||||
|
||||
if (props.base() == Algorithm::CN_2) {
|
||||
VARIANT2_SHUFFLE(l, idx, ax0, bx0, bx1, cx, (ALGO == Algorithm::CN_RWZ ? 1 : 0));
|
||||
VARIANT2_SHUFFLE(l, idx, ax0, bx0, bx1, cx, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0));
|
||||
_mm_store_si128(reinterpret_cast<__m128i *>(mem_out), _mm_xor_si128(bx0, cx));
|
||||
} else {
|
||||
__m128i tmp = _mm_xor_si128(bx0, cx);
|
||||
@@ -715,7 +720,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
||||
if (ALGO == Algorithm::CN_R) {
|
||||
VARIANT2_SHUFFLE(l0, idx0 & MASK, ax0, bx0, bx1, cx, 0);
|
||||
} else {
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx0, bx1, hi, lo, (ALGO == Algorithm::CN_RWZ ? 1 : 0));
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx0, bx1, hi, lo, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,8 +744,18 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||
if (props.isHeavy()) {
|
||||
int64_t n = ((int64_t*)&l0[interleaved_index<interleave>(idx0 & MASK)])[0];
|
||||
int32_t d = ((int32_t*)&l0[interleaved_index<interleave>(idx0 & MASK)])[2];
|
||||
int64_t q = n / (d | 0x5);
|
||||
int64_t d = ((int32_t*)&l0[interleaved_index<interleave>(idx0 & MASK)])[2];
|
||||
|
||||
int64_t d5;
|
||||
|
||||
# if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 8))
|
||||
d5 = d | 5;
|
||||
# else
|
||||
// Workaround for stupid GCC which converts to 32 bit before doing "| 5" and then converts back to 64 bit
|
||||
asm("mov %1, %0\n\tor $5, %0" : "=r"(d5) : "r"(d));
|
||||
# endif
|
||||
|
||||
int64_t q = n / d5;
|
||||
|
||||
((int64_t*)&l0[interleaved_index<interleave>(idx0 & MASK)])[0] = n ^ q;
|
||||
|
||||
@@ -779,6 +794,7 @@ extern "C" void cnv2_mainloop_bulldozer_asm(cryptonight_ctx **ctx);
|
||||
extern "C" void cnv2_double_mainloop_sandybridge_asm(cryptonight_ctx **ctx);
|
||||
extern "C" void cnv2_rwz_mainloop_asm(cryptonight_ctx **ctx);
|
||||
extern "C" void cnv2_rwz_double_mainloop_asm(cryptonight_ctx **ctx);
|
||||
extern "C" void cnv2_upx_double_mainloop_zen3_asm(cryptonight_ctx * *ctx);
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -812,6 +828,8 @@ extern cn_mainloop_fun cn_double_mainloop_ryzen_asm;
|
||||
extern cn_mainloop_fun cn_double_mainloop_bulldozer_asm;
|
||||
extern cn_mainloop_fun cn_double_double_mainloop_sandybridge_asm;
|
||||
|
||||
extern cn_mainloop_fun cn_upx2_mainloop_asm;
|
||||
extern cn_mainloop_fun cn_upx2_double_mainloop_asm;
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
@@ -924,6 +942,11 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
||||
cn_double_mainloop_bulldozer_asm(ctx);
|
||||
}
|
||||
}
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
else if (ALGO == Algorithm::CN_UPX2) {
|
||||
cn_upx2_mainloop_asm(ctx);
|
||||
}
|
||||
# endif
|
||||
else if (props.isR()) {
|
||||
ctx[0]->generated_code(ctx);
|
||||
}
|
||||
@@ -966,6 +989,16 @@ inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_
|
||||
else if (ALGO == Algorithm::CN_PICO_TLO) {
|
||||
cn_tlo_double_mainloop_sandybridge_asm(ctx);
|
||||
}
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
else if (ALGO == Algorithm::CN_UPX2) {
|
||||
if (Cpu::info()->arch() == ICpuInfo::ARCH_ZEN3) {
|
||||
cnv2_upx_double_mainloop_zen3_asm(ctx);
|
||||
}
|
||||
else {
|
||||
cn_upx2_double_mainloop_asm(ctx);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
else if (ALGO == Algorithm::CN_RWZ) {
|
||||
cnv2_rwz_double_mainloop_asm(ctx);
|
||||
@@ -1124,7 +1157,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
||||
if (ALGO == Algorithm::CN_R) {
|
||||
VARIANT2_SHUFFLE(l0, idx0 & MASK, ax0, bx00, bx01, cx0, 0);
|
||||
} else {
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx00, bx01, hi, lo, (ALGO == Algorithm::CN_RWZ ? 1 : 0));
|
||||
VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx00, bx01, hi, lo, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1182,7 +1215,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
||||
if (ALGO == Algorithm::CN_R) {
|
||||
VARIANT2_SHUFFLE(l1, idx1 & MASK, ax1, bx10, bx11, cx1, 0);
|
||||
} else {
|
||||
VARIANT2_SHUFFLE2(l1, idx1 & MASK, ax1, bx10, bx11, hi, lo, (ALGO == Algorithm::CN_RWZ ? 1 : 0));
|
||||
VARIANT2_SHUFFLE2(l1, idx1 & MASK, ax1, bx10, bx11, hi, lo, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1292,7 +1325,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
||||
if (ALGO == Algorithm::CN_R) { \
|
||||
VARIANT2_SHUFFLE(l, idx & MASK, a, b0, b1, c, 0); \
|
||||
} else { \
|
||||
VARIANT2_SHUFFLE2(l, idx & MASK, a, b0, b1, hi, lo, (ALGO == Algorithm::CN_RWZ ? 1 : 0)); \
|
||||
VARIANT2_SHUFFLE2(l, idx & MASK, a, b0, b1, hi, lo, (((ALGO == Algorithm::CN_RWZ) || (ALGO == Algorithm::CN_UPX2)) ? 1 : 0)); \
|
||||
} \
|
||||
} \
|
||||
if (ALGO == Algorithm::CN_R) { \
|
||||
|
||||
320
src/crypto/cn/asm/cn2/cnv2_upx_double_mainloop_zen3.inc
Normal file
320
src/crypto/cn/asm/cn2/cnv2_upx_double_mainloop_zen3.inc
Normal file
@@ -0,0 +1,320 @@
|
||||
mov rax, rsp
|
||||
push rbx
|
||||
push rbp
|
||||
push rsi
|
||||
push rdi
|
||||
push r12
|
||||
push r13
|
||||
push r14
|
||||
push r15
|
||||
sub rsp, 232
|
||||
|
||||
mov rdi, QWORD PTR [rcx+8]
|
||||
|
||||
mov edx, 768
|
||||
mov rbx, QWORD PTR [rcx]
|
||||
mov ecx, 256
|
||||
movaps XMMWORD PTR [rax-88], xmm6
|
||||
movaps XMMWORD PTR [rax-104], xmm7
|
||||
mov r13, QWORD PTR [rdi+224]
|
||||
movq xmm0, QWORD PTR [rdi+104]
|
||||
mov r12, QWORD PTR [rbx+224]
|
||||
movaps XMMWORD PTR [rax-120], xmm8
|
||||
movaps XMMWORD PTR [rax-136], xmm9
|
||||
movaps XMMWORD PTR [rax-152], xmm10
|
||||
movaps XMMWORD PTR [rsp+112], xmm11
|
||||
movaps XMMWORD PTR [rsp+96], xmm12
|
||||
movaps XMMWORD PTR [rsp+80], xmm13
|
||||
movq xmm13, QWORD PTR [rbx+96]
|
||||
movaps XMMWORD PTR [rsp+64], xmm14
|
||||
movq xmm14, QWORD PTR [rbx+104]
|
||||
movaps XMMWORD PTR [rsp+48], xmm15
|
||||
movq xmm15, QWORD PTR [rdi+96]
|
||||
mov QWORD PTR [rsp], r13
|
||||
movdqa XMMWORD PTR [rsp+32], xmm0
|
||||
|
||||
stmxcsr DWORD PTR [rsp+24]
|
||||
mov DWORD PTR [rsp+28], 16256
|
||||
ldmxcsr DWORD PTR [rsp+28]
|
||||
|
||||
mov rcx, QWORD PTR [rbx+56]
|
||||
xorps xmm12, xmm12
|
||||
xor rcx, QWORD PTR [rbx+24]
|
||||
mov rax, QWORD PTR [rbx+48]
|
||||
xor rax, QWORD PTR [rbx+16]
|
||||
mov rsi, QWORD PTR [rbx+32]
|
||||
mov rbp, QWORD PTR [rdi+32]
|
||||
movq xmm0, rcx
|
||||
|
||||
mov rcx, QWORD PTR [rbx+88]
|
||||
xor rcx, QWORD PTR [rbx+72]
|
||||
movq xmm7, rax
|
||||
mov rax, QWORD PTR [rbx+80]
|
||||
xor rax, QWORD PTR [rbx+64]
|
||||
mov r14, QWORD PTR [rbx+40]
|
||||
mov r15, QWORD PTR [rdi+40]
|
||||
xor rsi, QWORD PTR [rbx]
|
||||
xor rbp, QWORD PTR [rdi]
|
||||
movq xmm9, rax
|
||||
|
||||
mov rax, QWORD PTR [rdi+48]
|
||||
xor rax, QWORD PTR [rdi+16]
|
||||
xor r14, QWORD PTR [rbx+8]
|
||||
xor r15, QWORD PTR [rdi+8]
|
||||
movq xmm8, rax
|
||||
punpcklqdq xmm7, xmm0
|
||||
|
||||
mov eax, 1023
|
||||
shl rax, 52
|
||||
movq xmm11, rax
|
||||
punpcklqdq xmm11, xmm11
|
||||
|
||||
mov rax, QWORD PTR [rdi+80]
|
||||
movq xmm0, rcx
|
||||
mov rcx, QWORD PTR [rdi+56]
|
||||
xor rcx, QWORD PTR [rdi+24]
|
||||
punpcklqdq xmm9, xmm0
|
||||
mov QWORD PTR [rsp+8], 16384
|
||||
movq xmm0, rcx
|
||||
mov rcx, QWORD PTR [rdi+88]
|
||||
xor rcx, QWORD PTR [rdi+72]
|
||||
xor rax, QWORD PTR [rdi+64]
|
||||
punpcklqdq xmm8, xmm0
|
||||
movq xmm0, rcx
|
||||
movq xmm10, rax
|
||||
mov rax, 4389456576511
|
||||
mov QWORD PTR [rsp+16], rax
|
||||
mov rax, -4389456576512
|
||||
mov QWORD PTR [rsp+216], rax
|
||||
punpcklqdq xmm10, xmm0
|
||||
|
||||
ALIGN(64)
|
||||
upx2_main_loop:
|
||||
mov rdx, rsi
|
||||
mov r9, rbp
|
||||
and edx, 131056
|
||||
and r9d, 131056
|
||||
movdqu xmm6, XMMWORD PTR [rdx+r12]
|
||||
lea r8, QWORD PTR [rdx+r12]
|
||||
movdqu xmm4, XMMWORD PTR [r9+r13]
|
||||
lea r10, QWORD PTR [r9+r13]
|
||||
mov ecx, edx
|
||||
mov eax, edx
|
||||
xor rax, 32
|
||||
xor rcx, 48
|
||||
xor rdx, 16
|
||||
movq xmm0, r14
|
||||
movq xmm3, rsi
|
||||
movq xmm5, rbp
|
||||
punpcklqdq xmm3, xmm0
|
||||
movq xmm0, r15
|
||||
movdqu xmm2, XMMWORD PTR [rax+r12]
|
||||
movdqu xmm1, XMMWORD PTR [rcx+r12]
|
||||
paddq xmm2, xmm3
|
||||
punpcklqdq xmm5, xmm0
|
||||
paddq xmm1, xmm7
|
||||
aesenc xmm6, xmm3
|
||||
aesenc xmm4, xmm5
|
||||
movdqa xmm0, xmm9
|
||||
movq rdi, xmm4
|
||||
paddq xmm0, XMMWORD PTR [rdx+r12]
|
||||
movdqu XMMWORD PTR [rdx+r12], xmm0
|
||||
xor edx, edx
|
||||
movdqu XMMWORD PTR [rax+r12], xmm1
|
||||
movdqa xmm0, xmm6
|
||||
movdqu XMMWORD PTR [rcx+r12], xmm2
|
||||
pxor xmm0, xmm7
|
||||
movdqu XMMWORD PTR [r8], xmm0
|
||||
mov ecx, r9d
|
||||
xor rcx, 48
|
||||
mov eax, r9d
|
||||
xor rax, 32
|
||||
xor r9, 16
|
||||
movdqa xmm0, xmm10
|
||||
movdqu xmm1, XMMWORD PTR [rcx+r13]
|
||||
movdqu xmm2, XMMWORD PTR [rax+r13]
|
||||
paddq xmm1, xmm8
|
||||
paddq xmm0, XMMWORD PTR [r9+r13]
|
||||
paddq xmm2, xmm5
|
||||
movdqu XMMWORD PTR [r9+r13], xmm0
|
||||
movq r9, xmm6
|
||||
movdqu XMMWORD PTR [rax+r13], xmm1
|
||||
movdqa xmm0, xmm4
|
||||
movdqu XMMWORD PTR [rcx+r13], xmm2
|
||||
pxor xmm0, xmm8
|
||||
movdqu XMMWORD PTR [r10], xmm0
|
||||
movq rcx, xmm14
|
||||
mov rax, rcx
|
||||
movq r10, xmm13
|
||||
shl rax, 32
|
||||
movdqa xmm0, xmm6
|
||||
xor r10, rax
|
||||
psrldq xmm0, 8
|
||||
lea r8, QWORD PTR [rcx+rcx]
|
||||
movq rax, xmm0
|
||||
add r8d, r9d
|
||||
mov ecx, -2147483647
|
||||
or r8, rcx
|
||||
mov r11, r9
|
||||
div r8
|
||||
and r11d, 131056
|
||||
movaps xmm1, xmm12
|
||||
mov eax, eax
|
||||
add r11, r12
|
||||
shl rdx, 32
|
||||
add rdx, rax
|
||||
xor r10, QWORD PTR [r11]
|
||||
mov rbx, QWORD PTR [r11+8]
|
||||
lea r8, QWORD PTR [rdx+r9]
|
||||
movq xmm13, rdx
|
||||
mov rax, r8
|
||||
shr rax, 12
|
||||
movq xmm0, rax
|
||||
paddq xmm0, xmm11
|
||||
sqrtsd xmm1, xmm0
|
||||
movq rdx, xmm1
|
||||
mov rax, rdx
|
||||
shr rdx, 19
|
||||
shr rax, 20
|
||||
mov rcx, rdx
|
||||
sub rcx, rax
|
||||
add rax, QWORD PTR [rsp+216]
|
||||
sub rcx, QWORD PTR [rsp+16]
|
||||
mov r13, QWORD PTR [rsp]
|
||||
imul rcx, rax
|
||||
mov rax, r10
|
||||
sub rcx, r8
|
||||
mov rcx, r9
|
||||
adc rdx, 0
|
||||
xor rcx, 32
|
||||
and ecx, 131056
|
||||
movq xmm14, rdx
|
||||
movdqu xmm1, XMMWORD PTR [rcx+r12]
|
||||
mul r9
|
||||
paddq xmm1, xmm3
|
||||
mov r8, rax
|
||||
xor r8, QWORD PTR [rcx+r12+8]
|
||||
add r14, r8
|
||||
movq xmm0, rax
|
||||
movq xmm2, rdx
|
||||
xor rdx, QWORD PTR [rcx+r12]
|
||||
mov rax, r9
|
||||
xor rax, 48
|
||||
punpcklqdq xmm2, xmm0
|
||||
and eax, 131056
|
||||
add rsi, rdx
|
||||
xor r9, 16
|
||||
xor edx, edx
|
||||
and r9d, 131056
|
||||
movdqu xmm0, XMMWORD PTR [rax+r12]
|
||||
paddq xmm0, xmm7
|
||||
pxor xmm2, XMMWORD PTR [r9+r12]
|
||||
paddq xmm2, xmm9
|
||||
movdqu XMMWORD PTR [r9+r12], xmm2
|
||||
movq r9, xmm15
|
||||
movdqu XMMWORD PTR [rcx+r12], xmm0
|
||||
movdqa xmm0, xmm4
|
||||
mov rcx, QWORD PTR [rsp+32]
|
||||
movdqu XMMWORD PTR [rax+r12], xmm1
|
||||
mov rax, rcx
|
||||
shl rax, 32
|
||||
movaps xmm1, xmm12
|
||||
xor r9, rax
|
||||
psrldq xmm0, 8
|
||||
lea r8, QWORD PTR [rcx+rcx]
|
||||
mov QWORD PTR [r11], rsi
|
||||
add r8d, edi
|
||||
mov QWORD PTR [r11+8], r14
|
||||
movq rax, xmm0
|
||||
mov ecx, -2147483647
|
||||
or r8, rcx
|
||||
xor rsi, r10
|
||||
div r8
|
||||
mov r10, rdi
|
||||
xor r14, rbx
|
||||
mov eax, eax
|
||||
and r10d, 131056
|
||||
shl rdx, 32
|
||||
add r10, r13
|
||||
add rdx, rax
|
||||
xor r9, QWORD PTR [r10]
|
||||
mov r11, QWORD PTR [r10+8]
|
||||
lea r8, QWORD PTR [rdx+rdi]
|
||||
mov rax, r8
|
||||
movq xmm15, rdx
|
||||
shr rax, 12
|
||||
movq xmm0, rax
|
||||
paddq xmm0, xmm11
|
||||
sqrtsd xmm1, xmm0
|
||||
movq rdx, xmm1
|
||||
mov rax, rdx
|
||||
shr rax, 20
|
||||
shr rdx, 19
|
||||
mov rcx, rdx
|
||||
sub rcx, rax
|
||||
sub rcx, QWORD PTR [rsp+16]
|
||||
movdqa xmm9, xmm7
|
||||
movdqa xmm7, xmm6
|
||||
add rax, QWORD PTR [rsp+216]
|
||||
imul rcx, rax
|
||||
mov rax, r9
|
||||
sub rcx, r8
|
||||
mov rcx, rdi
|
||||
adc rdx, 0
|
||||
xor rcx, 32
|
||||
and ecx, 131056
|
||||
mov QWORD PTR [rsp+32], rdx
|
||||
movdqu xmm1, XMMWORD PTR [rcx+r13]
|
||||
mul rdi
|
||||
paddq xmm1, xmm5
|
||||
mov r8, rax
|
||||
xor r8, QWORD PTR [rcx+r13+8]
|
||||
add r15, r8
|
||||
movq xmm0, rax
|
||||
movq xmm2, rdx
|
||||
xor rdx, QWORD PTR [rcx+r13]
|
||||
mov rax, rdi
|
||||
xor rdi, 16
|
||||
punpcklqdq xmm2, xmm0
|
||||
xor rax, 48
|
||||
and edi, 131056
|
||||
and eax, 131056
|
||||
add rbp, rdx
|
||||
pxor xmm2, XMMWORD PTR [rdi+r13]
|
||||
movdqu xmm0, XMMWORD PTR [rax+r13]
|
||||
paddq xmm2, xmm10
|
||||
movdqu XMMWORD PTR [rdi+r13], xmm2
|
||||
paddq xmm0, xmm8
|
||||
movdqu XMMWORD PTR [rcx+r13], xmm0
|
||||
movdqa xmm10, xmm8
|
||||
movdqu XMMWORD PTR [rax+r13], xmm1
|
||||
movdqa xmm8, xmm4
|
||||
mov QWORD PTR [r10], rbp
|
||||
xor rbp, r9
|
||||
mov QWORD PTR [r10+8], r15
|
||||
xor r15, r11
|
||||
sub QWORD PTR [rsp+8], 1
|
||||
jne upx2_main_loop
|
||||
|
||||
ldmxcsr DWORD PTR [rsp+24]
|
||||
|
||||
movaps xmm13, XMMWORD PTR [rsp+80]
|
||||
lea r11, QWORD PTR [rsp+232]
|
||||
movaps xmm6, XMMWORD PTR [r11-24]
|
||||
movaps xmm7, XMMWORD PTR [r11-40]
|
||||
movaps xmm8, XMMWORD PTR [r11-56]
|
||||
movaps xmm9, XMMWORD PTR [r11-72]
|
||||
movaps xmm10, XMMWORD PTR [r11-88]
|
||||
movaps xmm11, XMMWORD PTR [r11-104]
|
||||
movaps xmm12, XMMWORD PTR [r11-120]
|
||||
movaps xmm14, XMMWORD PTR [rsp+64]
|
||||
movaps xmm15, XMMWORD PTR [rsp+48]
|
||||
mov rsp, r11
|
||||
pop r15
|
||||
pop r14
|
||||
pop r13
|
||||
pop r12
|
||||
pop rdi
|
||||
pop rsi
|
||||
pop rbp
|
||||
pop rbx
|
||||
@@ -17,6 +17,7 @@
|
||||
.global FN_PREFIX(cnv2_double_mainloop_sandybridge_asm)
|
||||
.global FN_PREFIX(cnv2_rwz_mainloop_asm)
|
||||
.global FN_PREFIX(cnv2_rwz_double_mainloop_asm)
|
||||
.global FN_PREFIX(cnv2_upx_double_mainloop_zen3_asm)
|
||||
|
||||
ALIGN(64)
|
||||
FN_PREFIX(cnv2_mainloop_ivybridge_asm):
|
||||
@@ -72,6 +73,15 @@ FN_PREFIX(cnv2_rwz_double_mainloop_asm):
|
||||
ret 0
|
||||
mov eax, 3735929054
|
||||
|
||||
ALIGN(64)
|
||||
FN_PREFIX(cnv2_upx_double_mainloop_zen3_asm):
|
||||
sub rsp, 48
|
||||
mov rcx, rdi
|
||||
#include "cn2/cnv2_upx_double_mainloop_zen3.inc"
|
||||
add rsp, 48
|
||||
ret 0
|
||||
mov eax, 3735929054
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -48,5 +48,12 @@ cnv2_rwz_double_mainloop_asm PROC
|
||||
mov eax, 3735929054
|
||||
cnv2_rwz_double_mainloop_asm ENDP
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_upx_double_mainloop_zen3_asm PROC
|
||||
INCLUDE cn2/cnv2_upx_double_mainloop_zen3.inc
|
||||
ret 0
|
||||
mov eax, 3735929054
|
||||
cnv2_upx_double_mainloop_zen3_asm ENDP
|
||||
|
||||
_TEXT_CNV2_MAINLOOP ENDS
|
||||
END
|
||||
|
||||
320
src/crypto/cn/asm/win64/cn2/cnv2_upx_double_mainloop_zen3.inc
Normal file
320
src/crypto/cn/asm/win64/cn2/cnv2_upx_double_mainloop_zen3.inc
Normal file
@@ -0,0 +1,320 @@
|
||||
mov rax, rsp
|
||||
push rbx
|
||||
push rbp
|
||||
push rsi
|
||||
push rdi
|
||||
push r12
|
||||
push r13
|
||||
push r14
|
||||
push r15
|
||||
sub rsp, 232
|
||||
|
||||
mov rdi, QWORD PTR [rcx+8]
|
||||
|
||||
mov edx, 768
|
||||
mov rbx, QWORD PTR [rcx]
|
||||
mov ecx, 256
|
||||
movaps XMMWORD PTR [rax-88], xmm6
|
||||
movaps XMMWORD PTR [rax-104], xmm7
|
||||
mov r13, QWORD PTR [rdi+224]
|
||||
movd xmm0, QWORD PTR [rdi+104]
|
||||
mov r12, QWORD PTR [rbx+224]
|
||||
movaps XMMWORD PTR [rax-120], xmm8
|
||||
movaps XMMWORD PTR [rax-136], xmm9
|
||||
movaps XMMWORD PTR [rax-152], xmm10
|
||||
movaps XMMWORD PTR [rsp+112], xmm11
|
||||
movaps XMMWORD PTR [rsp+96], xmm12
|
||||
movaps XMMWORD PTR [rsp+80], xmm13
|
||||
movd xmm13, QWORD PTR [rbx+96]
|
||||
movaps XMMWORD PTR [rsp+64], xmm14
|
||||
movd xmm14, QWORD PTR [rbx+104]
|
||||
movaps XMMWORD PTR [rsp+48], xmm15
|
||||
movd xmm15, QWORD PTR [rdi+96]
|
||||
mov QWORD PTR [rsp], r13
|
||||
movdqa XMMWORD PTR [rsp+32], xmm0
|
||||
|
||||
stmxcsr DWORD PTR [rsp+24]
|
||||
mov DWORD PTR [rsp+28], 16256
|
||||
ldmxcsr DWORD PTR [rsp+28]
|
||||
|
||||
mov rcx, QWORD PTR [rbx+56]
|
||||
xorps xmm12, xmm12
|
||||
xor rcx, QWORD PTR [rbx+24]
|
||||
mov rax, QWORD PTR [rbx+48]
|
||||
xor rax, QWORD PTR [rbx+16]
|
||||
mov rsi, QWORD PTR [rbx+32]
|
||||
mov rbp, QWORD PTR [rdi+32]
|
||||
movd xmm0, rcx
|
||||
|
||||
mov rcx, QWORD PTR [rbx+88]
|
||||
xor rcx, QWORD PTR [rbx+72]
|
||||
movd xmm7, rax
|
||||
mov rax, QWORD PTR [rbx+80]
|
||||
xor rax, QWORD PTR [rbx+64]
|
||||
mov r14, QWORD PTR [rbx+40]
|
||||
mov r15, QWORD PTR [rdi+40]
|
||||
xor rsi, QWORD PTR [rbx]
|
||||
xor rbp, QWORD PTR [rdi]
|
||||
movd xmm9, rax
|
||||
|
||||
mov rax, QWORD PTR [rdi+48]
|
||||
xor rax, QWORD PTR [rdi+16]
|
||||
xor r14, QWORD PTR [rbx+8]
|
||||
xor r15, QWORD PTR [rdi+8]
|
||||
movd xmm8, rax
|
||||
punpcklqdq xmm7, xmm0
|
||||
|
||||
mov eax, 1023
|
||||
shl rax, 52
|
||||
movd xmm11, rax
|
||||
punpcklqdq xmm11, xmm11
|
||||
|
||||
mov rax, QWORD PTR [rdi+80]
|
||||
movd xmm0, rcx
|
||||
mov rcx, QWORD PTR [rdi+56]
|
||||
xor rcx, QWORD PTR [rdi+24]
|
||||
punpcklqdq xmm9, xmm0
|
||||
mov QWORD PTR [rsp+8], 16384
|
||||
movd xmm0, rcx
|
||||
mov rcx, QWORD PTR [rdi+88]
|
||||
xor rcx, QWORD PTR [rdi+72]
|
||||
xor rax, QWORD PTR [rdi+64]
|
||||
punpcklqdq xmm8, xmm0
|
||||
movd xmm0, rcx
|
||||
movd xmm10, rax
|
||||
mov rax, 4389456576511
|
||||
mov QWORD PTR [rsp+16], rax
|
||||
mov rax, -4389456576512
|
||||
mov QWORD PTR [rsp+216], rax
|
||||
punpcklqdq xmm10, xmm0
|
||||
|
||||
ALIGN(64)
|
||||
upx2_main_loop:
|
||||
mov rdx, rsi
|
||||
mov r9, rbp
|
||||
and edx, 131056
|
||||
and r9d, 131056
|
||||
movdqu xmm6, XMMWORD PTR [rdx+r12]
|
||||
lea r8, QWORD PTR [rdx+r12]
|
||||
movdqu xmm4, XMMWORD PTR [r9+r13]
|
||||
lea r10, QWORD PTR [r9+r13]
|
||||
mov ecx, edx
|
||||
mov eax, edx
|
||||
xor rax, 32
|
||||
xor rcx, 48
|
||||
xor rdx, 16
|
||||
movd xmm0, r14
|
||||
movd xmm3, rsi
|
||||
movd xmm5, rbp
|
||||
punpcklqdq xmm3, xmm0
|
||||
movd xmm0, r15
|
||||
movdqu xmm2, XMMWORD PTR [rax+r12]
|
||||
movdqu xmm1, XMMWORD PTR [rcx+r12]
|
||||
paddq xmm2, xmm3
|
||||
punpcklqdq xmm5, xmm0
|
||||
paddq xmm1, xmm7
|
||||
aesenc xmm6, xmm3
|
||||
aesenc xmm4, xmm5
|
||||
movdqa xmm0, xmm9
|
||||
movd rdi, xmm4
|
||||
paddq xmm0, XMMWORD PTR [rdx+r12]
|
||||
movdqu XMMWORD PTR [rdx+r12], xmm0
|
||||
xor edx, edx
|
||||
movdqu XMMWORD PTR [rax+r12], xmm1
|
||||
movdqa xmm0, xmm6
|
||||
movdqu XMMWORD PTR [rcx+r12], xmm2
|
||||
pxor xmm0, xmm7
|
||||
movdqu XMMWORD PTR [r8], xmm0
|
||||
mov ecx, r9d
|
||||
xor rcx, 48
|
||||
mov eax, r9d
|
||||
xor rax, 32
|
||||
xor r9, 16
|
||||
movdqa xmm0, xmm10
|
||||
movdqu xmm1, XMMWORD PTR [rcx+r13]
|
||||
movdqu xmm2, XMMWORD PTR [rax+r13]
|
||||
paddq xmm1, xmm8
|
||||
paddq xmm0, XMMWORD PTR [r9+r13]
|
||||
paddq xmm2, xmm5
|
||||
movdqu XMMWORD PTR [r9+r13], xmm0
|
||||
movd r9, xmm6
|
||||
movdqu XMMWORD PTR [rax+r13], xmm1
|
||||
movdqa xmm0, xmm4
|
||||
movdqu XMMWORD PTR [rcx+r13], xmm2
|
||||
pxor xmm0, xmm8
|
||||
movdqu XMMWORD PTR [r10], xmm0
|
||||
movd rcx, xmm14
|
||||
mov rax, rcx
|
||||
movd r10, xmm13
|
||||
shl rax, 32
|
||||
movdqa xmm0, xmm6
|
||||
xor r10, rax
|
||||
psrldq xmm0, 8
|
||||
lea r8, QWORD PTR [rcx+rcx]
|
||||
movd rax, xmm0
|
||||
add r8d, r9d
|
||||
mov ecx, -2147483647
|
||||
or r8, rcx
|
||||
mov r11, r9
|
||||
div r8
|
||||
and r11d, 131056
|
||||
movaps xmm1, xmm12
|
||||
mov eax, eax
|
||||
add r11, r12
|
||||
shl rdx, 32
|
||||
add rdx, rax
|
||||
xor r10, QWORD PTR [r11]
|
||||
mov rbx, QWORD PTR [r11+8]
|
||||
lea r8, QWORD PTR [rdx+r9]
|
||||
movd xmm13, rdx
|
||||
mov rax, r8
|
||||
shr rax, 12
|
||||
movd xmm0, rax
|
||||
paddq xmm0, xmm11
|
||||
sqrtsd xmm1, xmm0
|
||||
movd rdx, xmm1
|
||||
mov rax, rdx
|
||||
shr rdx, 19
|
||||
shr rax, 20
|
||||
mov rcx, rdx
|
||||
sub rcx, rax
|
||||
add rax, QWORD PTR [rsp+216]
|
||||
sub rcx, QWORD PTR [rsp+16]
|
||||
mov r13, QWORD PTR [rsp]
|
||||
imul rcx, rax
|
||||
mov rax, r10
|
||||
sub rcx, r8
|
||||
mov rcx, r9
|
||||
adc rdx, 0
|
||||
xor rcx, 32
|
||||
and ecx, 131056
|
||||
movd xmm14, rdx
|
||||
movdqu xmm1, XMMWORD PTR [rcx+r12]
|
||||
mul r9
|
||||
paddq xmm1, xmm3
|
||||
mov r8, rax
|
||||
xor r8, QWORD PTR [rcx+r12+8]
|
||||
add r14, r8
|
||||
movd xmm0, rax
|
||||
movd xmm2, rdx
|
||||
xor rdx, QWORD PTR [rcx+r12]
|
||||
mov rax, r9
|
||||
xor rax, 48
|
||||
punpcklqdq xmm2, xmm0
|
||||
and eax, 131056
|
||||
add rsi, rdx
|
||||
xor r9, 16
|
||||
xor edx, edx
|
||||
and r9d, 131056
|
||||
movdqu xmm0, XMMWORD PTR [rax+r12]
|
||||
paddq xmm0, xmm7
|
||||
pxor xmm2, XMMWORD PTR [r9+r12]
|
||||
paddq xmm2, xmm9
|
||||
movdqu XMMWORD PTR [r9+r12], xmm2
|
||||
movd r9, xmm15
|
||||
movdqu XMMWORD PTR [rcx+r12], xmm0
|
||||
movdqa xmm0, xmm4
|
||||
mov rcx, QWORD PTR [rsp+32]
|
||||
movdqu XMMWORD PTR [rax+r12], xmm1
|
||||
mov rax, rcx
|
||||
shl rax, 32
|
||||
movaps xmm1, xmm12
|
||||
xor r9, rax
|
||||
psrldq xmm0, 8
|
||||
lea r8, QWORD PTR [rcx+rcx]
|
||||
mov QWORD PTR [r11], rsi
|
||||
add r8d, edi
|
||||
mov QWORD PTR [r11+8], r14
|
||||
movd rax, xmm0
|
||||
mov ecx, -2147483647
|
||||
or r8, rcx
|
||||
xor rsi, r10
|
||||
div r8
|
||||
mov r10, rdi
|
||||
xor r14, rbx
|
||||
mov eax, eax
|
||||
and r10d, 131056
|
||||
shl rdx, 32
|
||||
add r10, r13
|
||||
add rdx, rax
|
||||
xor r9, QWORD PTR [r10]
|
||||
mov r11, QWORD PTR [r10+8]
|
||||
lea r8, QWORD PTR [rdx+rdi]
|
||||
mov rax, r8
|
||||
movd xmm15, rdx
|
||||
shr rax, 12
|
||||
movd xmm0, rax
|
||||
paddq xmm0, xmm11
|
||||
sqrtsd xmm1, xmm0
|
||||
movd rdx, xmm1
|
||||
mov rax, rdx
|
||||
shr rax, 20
|
||||
shr rdx, 19
|
||||
mov rcx, rdx
|
||||
sub rcx, rax
|
||||
sub rcx, QWORD PTR [rsp+16]
|
||||
movdqa xmm9, xmm7
|
||||
movdqa xmm7, xmm6
|
||||
add rax, QWORD PTR [rsp+216]
|
||||
imul rcx, rax
|
||||
mov rax, r9
|
||||
sub rcx, r8
|
||||
mov rcx, rdi
|
||||
adc rdx, 0
|
||||
xor rcx, 32
|
||||
and ecx, 131056
|
||||
mov QWORD PTR [rsp+32], rdx
|
||||
movdqu xmm1, XMMWORD PTR [rcx+r13]
|
||||
mul rdi
|
||||
paddq xmm1, xmm5
|
||||
mov r8, rax
|
||||
xor r8, QWORD PTR [rcx+r13+8]
|
||||
add r15, r8
|
||||
movd xmm0, rax
|
||||
movd xmm2, rdx
|
||||
xor rdx, QWORD PTR [rcx+r13]
|
||||
mov rax, rdi
|
||||
xor rdi, 16
|
||||
punpcklqdq xmm2, xmm0
|
||||
xor rax, 48
|
||||
and edi, 131056
|
||||
and eax, 131056
|
||||
add rbp, rdx
|
||||
pxor xmm2, XMMWORD PTR [rdi+r13]
|
||||
movdqu xmm0, XMMWORD PTR [rax+r13]
|
||||
paddq xmm2, xmm10
|
||||
movdqu XMMWORD PTR [rdi+r13], xmm2
|
||||
paddq xmm0, xmm8
|
||||
movdqu XMMWORD PTR [rcx+r13], xmm0
|
||||
movdqa xmm10, xmm8
|
||||
movdqu XMMWORD PTR [rax+r13], xmm1
|
||||
movdqa xmm8, xmm4
|
||||
mov QWORD PTR [r10], rbp
|
||||
xor rbp, r9
|
||||
mov QWORD PTR [r10+8], r15
|
||||
xor r15, r11
|
||||
sub QWORD PTR [rsp+8], 1
|
||||
jne upx2_main_loop
|
||||
|
||||
ldmxcsr DWORD PTR [rsp+24]
|
||||
|
||||
movaps xmm13, XMMWORD PTR [rsp+80]
|
||||
lea r11, QWORD PTR [rsp+232]
|
||||
movaps xmm6, XMMWORD PTR [r11-24]
|
||||
movaps xmm7, XMMWORD PTR [r11-40]
|
||||
movaps xmm8, XMMWORD PTR [r11-56]
|
||||
movaps xmm9, XMMWORD PTR [r11-72]
|
||||
movaps xmm10, XMMWORD PTR [r11-88]
|
||||
movaps xmm11, XMMWORD PTR [r11-104]
|
||||
movaps xmm12, XMMWORD PTR [r11-120]
|
||||
movaps xmm14, XMMWORD PTR [rsp+64]
|
||||
movaps xmm15, XMMWORD PTR [rsp+48]
|
||||
mov rsp, r11
|
||||
pop r15
|
||||
pop r14
|
||||
pop r13
|
||||
pop r12
|
||||
pop rdi
|
||||
pop rsi
|
||||
pop rbp
|
||||
pop rbx
|
||||
@@ -7,6 +7,7 @@
|
||||
.global cnv2_double_mainloop_sandybridge_asm
|
||||
.global cnv2_rwz_mainloop_asm
|
||||
.global cnv2_rwz_double_mainloop_asm
|
||||
.global cnv2_upx_double_mainloop_zen3_asm
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_mainloop_ivybridge_asm:
|
||||
@@ -43,3 +44,9 @@ cnv2_rwz_double_mainloop_asm:
|
||||
#include "cn2/cnv2_rwz_double_main_loop.inc"
|
||||
ret 0
|
||||
mov eax, 3735929054
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_upx_double_mainloop_zen3_asm:
|
||||
#include "cn2/cnv2_upx_double_mainloop_zen3.inc"
|
||||
ret 0
|
||||
mov eax, 3735929054
|
||||
|
||||
@@ -48,5 +48,12 @@ cnv2_rwz_double_mainloop_asm PROC
|
||||
mov eax, 3735929054
|
||||
cnv2_rwz_double_mainloop_asm ENDP
|
||||
|
||||
ALIGN(64)
|
||||
cnv2_upx_double_mainloop_zen3_asm PROC
|
||||
INCLUDE cn2/cnv2_upx_double_mainloop_zen3.inc
|
||||
ret 0
|
||||
mov eax, 3735929054
|
||||
cnv2_upx_double_mainloop_zen3_asm ENDP
|
||||
|
||||
_TEXT_CNV2_MAINLOOP ENDS
|
||||
END
|
||||
|
||||
@@ -343,7 +343,7 @@ typedef union ALIGN_STRUCT(16) SIMDVec {
|
||||
|
||||
// Older gcc does not define vld1q_u8_x4 type
|
||||
#if defined(__GNUC__) && !defined(__clang__) && \
|
||||
((__GNUC__ == 10 && (__GNUC_MINOR__ <= 1)) || \
|
||||
((__GNUC__ == 10 && (__GNUC_MINOR__ <= 2)) || \
|
||||
(__GNUC__ == 9 && (__GNUC_MINOR__ <= 3)) || \
|
||||
(__GNUC__ == 8 && (__GNUC_MINOR__ <= 4)) || __GNUC__ <= 7)
|
||||
FORCE_INLINE uint8x16x4_t _sse2neon_vld1q_u8_x4(const uint8_t *p)
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
size_t size = 0;
|
||||
|
||||
inline bool isFullyAllocated() const { return allocated == total; }
|
||||
inline double percent() const { return allocated == 0 ? 0.0 : static_cast<double>(allocated) / total * 100.0; }
|
||||
inline double percent() const { return total == 0 ? 0.0 : static_cast<double>(allocated) / total * 100.0; }
|
||||
inline void reset() { allocated = 0; total = 0; size = 0; }
|
||||
|
||||
inline HugePagesInfo &operator+=(const HugePagesInfo &other)
|
||||
|
||||
17
src/crypto/randomx/asm/program_imul_rcp_store.inc
Normal file
17
src/crypto/randomx/asm/program_imul_rcp_store.inc
Normal file
@@ -0,0 +1,17 @@
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
db 72, 185, 0, 0, 0, 0, 0, 0, 0, 0, 81
|
||||
add rsp, 128
|
||||
@@ -103,7 +103,7 @@ namespace randomx {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
#if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__))
|
||||
#define RANDOMX_HAVE_COMPILER 1
|
||||
class JitCompilerX86;
|
||||
using JitCompiler = JitCompilerX86;
|
||||
|
||||
@@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
#if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__))
|
||||
#include "crypto/randomx/jit_compiler_x86.hpp"
|
||||
#elif defined(__aarch64__)
|
||||
#include "crypto/randomx/jit_compiler_a64.hpp"
|
||||
|
||||
@@ -428,7 +428,10 @@ namespace randomx {
|
||||
xmrig::RxFix::setMainLoopBounds(mainLoopBounds);
|
||||
# endif
|
||||
|
||||
memcpy(code + prologueSize - 48, &pcfg.eMask, sizeof(pcfg.eMask));
|
||||
imul_rcp_storage = code + (ADDR(randomx_program_imul_rcp_store) - codePrologue) + 2;
|
||||
imul_rcp_storage_used = 0;
|
||||
|
||||
memcpy(imul_rcp_storage - 34, &pcfg.eMask, sizeof(pcfg.eMask));
|
||||
codePos = codePosFirst;
|
||||
prevCFROUND = 0;
|
||||
|
||||
@@ -1012,13 +1015,24 @@ namespace randomx {
|
||||
|
||||
uint64_t divisor = instr.getImm32();
|
||||
if (!isZeroOrPowerOf2(divisor)) {
|
||||
*(uint32_t*)(p + pos) = 0xb848;
|
||||
pos += 2;
|
||||
|
||||
emit64(randomx_reciprocal_fast(divisor), p, pos);
|
||||
|
||||
const uint32_t dst = instr.dst % RegistersCount;
|
||||
emit32(0xc0af0f4c + (dst << 27), p, pos);
|
||||
|
||||
const uint64_t reciprocal = randomx_reciprocal_fast(divisor);
|
||||
if (imul_rcp_storage_used < 16) {
|
||||
*(uint64_t*)(imul_rcp_storage) = reciprocal;
|
||||
*(uint64_t*)(p + pos) = 0x2444AF0F4Cull + (dst << 27) + (static_cast<uint64_t>(248 - imul_rcp_storage_used * 8) << 40);
|
||||
++imul_rcp_storage_used;
|
||||
imul_rcp_storage += 11;
|
||||
pos += 6;
|
||||
}
|
||||
else {
|
||||
*(uint32_t*)(p + pos) = 0xb848;
|
||||
pos += 2;
|
||||
|
||||
emit64(reciprocal, p, pos);
|
||||
|
||||
emit32(0xc0af0f4c + (dst << 27), p, pos);
|
||||
}
|
||||
|
||||
registerUsage[dst] = pos;
|
||||
}
|
||||
|
||||
@@ -104,6 +104,9 @@ namespace randomx {
|
||||
uint8_t* allocatedCode = nullptr;
|
||||
size_t allocatedSize = 0;
|
||||
|
||||
uint8_t* imul_rcp_storage = nullptr;
|
||||
uint32_t imul_rcp_storage_used = 0;
|
||||
|
||||
void generateProgramPrologue(Program&, ProgramConfiguration&);
|
||||
void generateProgramEpilogue(Program&, ProgramConfiguration&);
|
||||
template<bool rax>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
.global DECL(randomx_prefetch_scratchpad_end)
|
||||
.global DECL(randomx_program_prologue)
|
||||
.global DECL(randomx_program_prologue_first_load)
|
||||
.global DECL(randomx_program_imul_rcp_store)
|
||||
.global DECL(randomx_program_loop_begin)
|
||||
.global DECL(randomx_program_loop_load)
|
||||
.global DECL(randomx_program_loop_load_xop)
|
||||
@@ -106,11 +107,15 @@ DECL(randomx_program_prologue_first_load):
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
jmp DECL(randomx_program_loop_begin)
|
||||
jmp DECL(randomx_program_imul_rcp_store)
|
||||
|
||||
.balign 64
|
||||
#include "asm/program_xmm_constants.inc"
|
||||
|
||||
DECL(randomx_program_imul_rcp_store):
|
||||
#include "asm/program_imul_rcp_store.inc"
|
||||
jmp DECL(randomx_program_loop_begin)
|
||||
|
||||
.balign 64
|
||||
DECL(randomx_program_loop_begin):
|
||||
nop
|
||||
|
||||
@@ -32,6 +32,7 @@ PUBLIC randomx_prefetch_scratchpad
|
||||
PUBLIC randomx_prefetch_scratchpad_end
|
||||
PUBLIC randomx_program_prologue
|
||||
PUBLIC randomx_program_prologue_first_load
|
||||
PUBLIC randomx_program_imul_rcp_store
|
||||
PUBLIC randomx_program_loop_begin
|
||||
PUBLIC randomx_program_loop_load
|
||||
PUBLIC randomx_program_loop_load_xop
|
||||
@@ -94,12 +95,17 @@ randomx_program_prologue_first_load PROC
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
jmp randomx_program_loop_begin
|
||||
jmp randomx_program_imul_rcp_store
|
||||
randomx_program_prologue_first_load ENDP
|
||||
|
||||
ALIGN 64
|
||||
include asm/program_xmm_constants.inc
|
||||
|
||||
randomx_program_imul_rcp_store PROC
|
||||
include asm/program_imul_rcp_store.inc
|
||||
jmp randomx_program_loop_begin
|
||||
randomx_program_imul_rcp_store ENDP
|
||||
|
||||
ALIGN 64
|
||||
randomx_program_loop_begin PROC
|
||||
nop
|
||||
|
||||
@@ -33,6 +33,7 @@ extern "C" {
|
||||
void randomx_prefetch_scratchpad_end();
|
||||
void randomx_program_prologue();
|
||||
void randomx_program_prologue_first_load();
|
||||
void randomx_program_imul_rcp_store();
|
||||
void randomx_program_loop_begin();
|
||||
void randomx_program_loop_load();
|
||||
void randomx_program_loop_load_xop();
|
||||
|
||||
@@ -148,7 +148,7 @@ RandomX_ConfigurationBase::RandomX_ConfigurationBase()
|
||||
fillAes4Rx4_Key[6] = rx_set_int_vec_i128(0xf63befa7, 0x2ba9660a, 0xf765a38b, 0xf273c9e7);
|
||||
fillAes4Rx4_Key[7] = rx_set_int_vec_i128(0xc0b0762d, 0x0c06d1fd, 0x915839de, 0x7a7cd609);
|
||||
|
||||
# if defined(_M_X64) || defined(__x86_64__)
|
||||
# if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__))
|
||||
// Workaround for Visual Studio placing trampoline in debug builds.
|
||||
auto addr = [](void (*func)()) {
|
||||
const uint8_t* p = reinterpret_cast<const uint8_t*>(func);
|
||||
@@ -214,7 +214,7 @@ void RandomX_ConfigurationBase::Apply()
|
||||
ScratchpadL3Mask_Calculated = (((ScratchpadL3_Size / sizeof(uint64_t)) - 1) * 8);
|
||||
ScratchpadL3Mask64_Calculated = ((ScratchpadL3_Size / sizeof(uint64_t)) / 8 - 1) * 64;
|
||||
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
#if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__))
|
||||
*(uint32_t*)(codeShhPrefetchTweaked + 3) = ArgonMemory * 16 - 1;
|
||||
// Not needed right now because all variants use default dataset base size
|
||||
//const uint32_t DatasetBaseMask = DatasetBaseSize - RANDOMX_DATASET_ITEM_SIZE;
|
||||
|
||||
@@ -28,15 +28,15 @@
|
||||
#define APP_ID "xmrig"
|
||||
#define APP_NAME "XMRig"
|
||||
#define APP_DESC "XMRig miner"
|
||||
#define APP_VERSION "6.10.0"
|
||||
#define APP_VERSION "6.12.1"
|
||||
#define APP_DOMAIN "xmrig.com"
|
||||
#define APP_SITE "www.xmrig.com"
|
||||
#define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com"
|
||||
#define APP_KIND "miner"
|
||||
|
||||
#define APP_VER_MAJOR 6
|
||||
#define APP_VER_MINOR 10
|
||||
#define APP_VER_PATCH 0
|
||||
#define APP_VER_MINOR 12
|
||||
#define APP_VER_PATCH 1
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if (_MSC_VER >= 1920)
|
||||
|
||||
Reference in New Issue
Block a user